java - How to format a number from other locale to normal en locale -


i have string "45,78". how can format normal format 45.78 in java?

probably think need create format object , format according en number format.
how can that?

use predefined decimalformats jdk offers locales:

public static void main(string[] args) throws parseexception {     string input = "45,78";     numberformat = decimalformat.getnumberinstance(locale.france);     numberformat = decimalformat.getnumberinstance(locale.us);     string output = to.format(from.parse(input));     system.out.println(output); // "45.78" } 

chose locales suit you.

this case of "don't reinvent wheel" , "use jdk offers"


Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -