Java issue converting String to double -


i'm trying convert string double.

the source string in format "88.6" , double expect should "88.60".

i tried converting using double.parsedouble, double constructor, double.valueof, decimalformat , numberformat hardcoding locale.us or locale.english still "88,600000".

how should convert it?

thanks

decimalformat df = new decimalformat("#.##", new decimalformatsymbols(locale.us)); try {     dvalue = df.parse(szvalue).doublevalue(); } catch(parseexception e) {     e.printstacktrace(); } 

while don't think keeping trailing zeros necessary, think asking for:

    decimalformatsymbols dfs = new decimalformatsymbols();     dfs.setdecimalseparator('.');     java.text.decimalformat df = new java.text.decimalformat();       df.setdecimalformatsymbols(dfs);     df.applypattern( "###0.00" );     string s = "9.90" ;     system.out.println("non formated d=" + double.valueof(s) + " formated d=" +df.format(double.valueof(s)));    

the trailing zeros visible when printing them, need format number


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -