• Post Reply Bookmark Topic Watch Topic
  • New Topic

DecimalFormat that takes a Locale  RSS feed

 
Maria Kowalczyk
Greenhorn
Posts: 15
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with my format method. It is Locale-depentent (as DecimalFormat uses machine's default locale).
I tried to found a solution for that that allows me to use the same output but with fixed Locale.US (or any other locale I might want to pass ).
I found that NumberFormat class takes a Locale as an argument in its factory methods but I haven't found a method that takes a String pattern.
I'm stuck. I want a Locale setting from NumberFormat and also String-pattern setting from DecimalFormat.
Can you help me?
 
Maxim Karvonen
Ranch Hand
Posts: 121
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Maria.

Locale and "Format string" are not compatible because Locale settings includes some aspects of formatting (such as grouping). It's hard to describe how "locale-specific" setting should interact with "format-string" settings.

However, I think, you actually tries to ask something slightly different. Probably you want not a "US-locale number format", but "US-locale number special characters". This is compatible with a format string (format string defines only kinds of character but not mapping from any kind to an actual character). And this is easily achievable. Starting point will be DecimalFormatSymbols class, it's two constructors and list of all DecimalFormat constructors.
 
Maria Kowalczyk
Greenhorn
Posts: 15
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks . Buziak :*
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!