z22
z22

Reputation: 10083

store percent value in mysql using bigdecimal

How do I store percent value in MySQL using BigDecimal?

I used the following code to do so:

chngePer=new BigDecimal(st.nextToken().trim().replace("%", "")).divide(BigDecimal.valueOf(100));

but it gives me numberFormatException.

I am using a CSV file and storing each of its values in stringTokenizer st. One of its values is like -0.45%. How do I store it in the database?

StringTokenizer st=new StringTokenizer(nextLine, ",");
chngePer=new BigDecimal(st.nextToken().trim().replace("%", "")).divide(BigDecimal.valueOf(100));

edit : contents of token

Upvotes: 0

Views: 654

Answers (1)

Buhb
Buhb

Reputation: 7149

Perhaps you need to remove the quotes.

Upvotes: 2

Related Questions