added formatting using Locales

This commit is contained in:
Vaibhav Sahay 2018-09-08 00:25:25 +05:30 committed by GitHub
parent 0da07de99e
commit 37544c141b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -18,6 +18,19 @@ public class DoubletoString {
df.setRoundingMode(RoundingMode.FLOOR);
System.out.println(df.format(doubleValue));
Locale enlocale = new Locale("en", "US");
String pattern = "###,##";
df = (DecimalFormat) NumberFormat.getNumberInstance(enlocale);
df.applyPattern(pattern);
String format = df.format(doubleValue);
System.out.println(format);
Locale dalocale = new Locale("da", "DK");
df = (DecimalFormat) NumberFormat.getNumberInstance(dalocale);
df.applyPattern(pattern);
System.out.println(df.format(doubleValue));
}
}