0

I'm trying to import a CSV file into Java, but when I reach the timestamp value (for instance: 135824328205) I get the following message:

02-25 10:40:48.629: W/System.err(23341): java.lang.NumberFormatException: 1.35998E+12

I would like to store it as a long value, but it isn't works, here is my code:

in.setTS(Long.parseLong(dataArray[2]));

Can anybody help me ? Thanks.

Apurv
  • 3,723
  • 3
  • 30
  • 51
narancs
  • 5,234
  • 4
  • 41
  • 60

2 Answers2

1

As you can see here:

in.setTS(Double.valueOf(dataArray[2]).longValue());

in case dataArray[2] holds the relevant exponential notation as string

BigInteger can also help you here.

Community
  • 1
  • 1
BobTheBuilder
  • 18,858
  • 6
  • 40
  • 61
0

For huge numbers it is highly useful to use BigInteger

BigInteger value = new BigInteger(dataArray[2], 10);

Assuming dataArray[2] is string

Refer documentation

asifsid88
  • 4,631
  • 20
  • 30