Skip to content

Commit 37544c1

Browse files
authored
added formatting using Locales
1 parent 0da07de commit 37544c1

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎core-java/DoubletoString.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ public static void main(String[] args) {
1717
DecimalFormat df = new DecimalFormat("#");
1818
df.setRoundingMode(RoundingMode.FLOOR);
1919
System.out.println(df.format(doubleValue));
20+
21+
Locale enlocale = new Locale("en", "US");
22+
String pattern = "###,##";
23+
df = (DecimalFormat) NumberFormat.getNumberInstance(enlocale);
24+
df.applyPattern(pattern);
25+
String format = df.format(doubleValue);
26+
System.out.println(format);
27+
28+
Locale dalocale = new Locale("da", "DK");
29+
df = (DecimalFormat) NumberFormat.getNumberInstance(dalocale);
30+
df.applyPattern(pattern);
31+
System.out.println(df.format(doubleValue));
32+
2033

2134
}
2235

0 commit comments

Comments
 (0)