java - BigDecimal.doubleValue() somehow yielded an incorrect result -


i have class (let's call money) handles calculation of monetary values. it's wrapper bigdecimal , uses correct decimal precision money. has worked pretty many years, have had incident had major repercussions , need determine cause, , if use of class cause.

we read values excel file using jexcelapi. use api because files working excel 2003 files. value read file using getcontents method. field in excel file in general format , after reading it, result instantiates new instance of money class using following static method of money class:

public static money valueof(string s, int precision) {     try {         number n = format.parse(s);         return new money(new bigdecimal(n.doublevalue()), precision);     }     catch (parseexception e) {         throw new illegalargumentexception("cannot convert money " + s);     } } 

precision 2 , format instance of decimalformat("#0.00###;-0.00###")

e.g.

money amount = money.valueof(sheet.getcell(col, row).getcontents()); 

so value of 1500 (no decimals) used in sheet , used input. happened value somehow got duplicated in following way 15150000 creating severely overstated amount. it's if same value pushed in between digits. instead of 1500, value 15 million.

i've have not been able replicate problem. values calculated correctly. it's quite possible system operating @ peak @ time , swap space being used, don't see how affect 1 record of on 3500 records same amount.

any ideas? possible memory not cleared?

our technology stack:
ubuntu 15.04 8gb ram
java 8
tomcat 8.5
mysql 5.7.15


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -