开发者

How does "Format editor" for JFormatedTextField in NetBeans work?

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.

How does "Format editor" for JFormatedTextField in NetBeans work?

For #,##0.### , it returns 1,234.5开发者_C百科67, 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜