Converting Double to String without scientific (E) notation in java
A numeric field in excel files was represented as string in database. Even though this number was not used for calculation, it seems for some reason, the database designer has kept it that way! Trouble started when the POI library’s getNumericCellValue() method returned the numbers in the form of scientific notation. The number 12,345,600 would be returned as 123.456E5. But I need it in plain text 1245600 without scientific notation and grouping of numbers!
Solution to this problem lies in configuring NumberFormat or DecimalFormat class found in the package java.text. Here is solution code:
Double comSysNumber = Cell.getNumericCellValue();
NumberFormat f = NumberFormat.getInstance();
f.setGroupingUsed(false);
String refinedNumber = f.format(comSysNumber);
Now the string variable refinedNumber is all set to be stored into my database
. Hope this becomes useful to others.
I just reshare, Thanks to this post: http://technopaper.blogspot.com/2009/06/converting-double-to-string-without-e.html



