tags:

views:

39

answers:

1

I need to edit format for JFormatedTextField in a Java program. NetBeans are "helping" me with something called Format editor. But, I have no clue how the pattern works. format editor

For #,##0.### , it returns 1,234.567, as pictured above. However, I want to change the thousands delimiter to space and decimal separator to comma.

I would guess # ##0,### is the right format, but no, that returns "Malformed pattern # ##0,###".

How can I change the thousand separator to space and decimal to comma? Is that even possible, using Format editor?

A: 

It sounds like you're looking for the reference for the java.text.NumberFormat class.

The DecimalFormatSymbols.getGroupingSeparator method looks like it is probably relevant to what you're doing. You will have to choose an appropriate Locale to get the formatting characters you want.

You may need to do something like:

NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH);

with an appropriate parameter to getInstance() for your country and language.

Greg Hewgill
it's not EXACTLY what I wanted, and I still don't understand the mysteries of this Format editor, but you set me on the right track, so thanks!
Karel Bílek