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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -