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
- “TATA CONSULTANCY ”
- 654914
- 5
- +2.2999
- “+0.19%”
- “5/23/2012”
Perhaps you need to remove the quotes.