dimanche 17 juillet 2016

JAVA - How to convert different kind of numbers to BigDecimal

i have read other similar questions and answers, but all of them doesn't suit my problem. So here is my problem, i have a java class, where i import from a CSV file different kind of numbers to save it into my MySQL DB, numbers are like this:

26.9
917883949.5
119.23
0
37.18
23515030314.3
12.71
11.85

So i try to convert this numbers into BigDecimal like this (it is used for my MySQL PreparedStatement):

prep.setBigDecimal(3, new BigDecimal(num));

Type of num is String.

but i always get this error:

> java.lang.NumberFormatException
    at java.math.BigDecimal.<init>(Unknown Source)

Some hints would be nice.

Thanks.

Aucun commentaire:

Enregistrer un commentaire