java - Using Default Locale Separator with NumberFormat, and then rounding number -
i have java code:
numberformat nf = numberformat.getnumberinstance(locale.getdefault()); decimalformat df = (decimalformat)nf; newcurr = df.format(dcurr);
basically, pass in number, 12.344.
i want rounded 2 places , use locale's default separator (either "." or ","). so, example in countries in europe, want 12,34
so far code above, halfway there. 12,344. can't find place decimalformat
of ("#.##") can rounded.
in other words, can incorporate decimalformat df=new decimalformat("#.##");
in above? or have find way?
edit: thinking have old way of (100.00 * var)/ 100.00 , pass in?
the method setmaximumfractiondigit work. see rest of available methods: http://docs.oracle.com/javase/7/docs/api/java/text/decimalformat.html#setmaximumfractiondigits%28int%29
Comments
Post a Comment