3
I was trying to format a number by placing stitches to make it easier to read.
But with the dot it doesn’t work, but it works with commas.
Ex:
String s = String.format("%. d", 123456);
System.out.println(s);
3
I was trying to format a number by placing stitches to make it easier to read.
But with the dot it doesn’t work, but it works with commas.
Ex:
String s = String.format("%. d", 123456);
System.out.println(s);
4
The %,d is the thousand separator, and will use the default JVM location unless you specify different. To force the Brazilian location using point as separator, unlike the American using comma you can:
String.format(new Locale("pt"),"%,d",1234567)
Browser other questions tagged java
You are not signed in. Login or sign up in order to post.
Just to complement: when developing an application, it is essential to think about localization (I10n) and internationalization (I18n), even if the system is only used in one language, because the program may be affected by the operating system settings or the installed version of Java. So a good practice is to have the locality (
Locale
) as a configuration of the program and then use it in all routines involving locale. In other words: never use theLocale
standard in a production system.– utluiz