guava icon indicating copy to clipboard operation
guava copied to clipboard

String.format(Locale.ROOT, ...) wrapper

Open cpovirk opened this issue 10 years ago • 5 comments

String.format depends on the default locale, leading to problems like #1567. We can fix it by passing Locale.ROOT to each call, but this is kind of ugly, especially for an API that exists in large part to eliminate ugly string-concatenation code.

Where would it go?

  • Strings.format: looks like String.format, possibly too much so
  • Strings.rootLocaleFormat: for easy static import
  • RootLocale.format: gives a place for future such methods. Are there any candidates?

And how worried are we about use of the default locale here? Oddly, I'm not sure I've ever heard anyone crusading against String.format, even though there are crusaders against many other default-locale APIs. Maybe it's just less frequently noticed there, in part because users often just use %s? Plus, the output is probably more often used for debugging than it would be for, e.g., SimpleDateFormat.

cpovirk avatar Jan 13 '15 18:01 cpovirk