java - how to format a string value to double decimal format -


number format nf = numberformat.getnumberinstance(locale.us);  decimalformat df = (decimalformat)nf; df.applypattern("$###,###.###"); string format_val=df.format(4596.37); num = new jxl.write.number(i, j,double.parsedouble(format_val),arial10format); 

here i'm getting numberformatexception :

java.lang.numberformatexception: input string: "$4,596.37" 

how solve one?

what "think" want (i've not tried this) let cell take care of formatting, example...

numberformat decimalno = new numberformat("$###,###.###");  writablecellformat numberformat = new writablecellformat(decimalno); //write datasheet number numbercell = new number(i, j, 4596.37, numberformat);  excelsheet.addcell(numbercell); 

take @ writablecellformat more details

what you've tried is...

  1. convert double value 4596.37 string, format of $###,###.###
  2. try , convert $4,596.37 double...which fails string you've passed not conform requirements of double...

a number has no concept of format, that's formatters for. in case, however, excel cell has it's own internal formatting capabilities can take care of you


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -