Wish JLocale library

Yafuhenk

Active Member
Licensed User
Longtime User
Hi,

I struggle with decimal format symbols. In the csv file I read the number are formatted as follows 1,234.56, however here we use 1.234,56 and this format I want to store in the db
I really would like to have a Locale library / class for B4J
Something like this: http://docs.oracle.com/javase/6/docs/api/java/text/DecimalFormatSymbols.html

Or is there another solution?
I now change the "." and "," symbols but this is a big potential risk of course in case the csv file has for example a dutch or german decimal layout
 

Yafuhenk

Active Member
Licensed User
Longtime User
Lets imagine that I know the format, what is in that case the best way to go. Change "." and ","?
 

dilettante

Active Member
Licensed User
Longtime User
The normal practice is to store as much as possible in binary formats, and store text when required in "invariant locale" format (which just happens to be US English for historical reasons). This becomes even more important for data interchange, and even more so when sharing data via web services and other techniques with global reach.

But for purposes of data entry, display, and reporting you probably really do want locale-aware formatting and value parsing as well as invariant-locale versions of the same things.

It doesn't help much that the terms casting and conversion are frequently treated as interchangable when they are two different things. Oh well.

In B4J we seem to be relying on implicit conversions all over the place, which I personally find disturbing. Right now I have no idea whether these are locale-aware (which could break a lot of programs) or locale-blind using the invariant locale. And I have no idea how to do explicit conversions using the invariant locale, the current locale, or a specified locale.
 
Top