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,675
  • 3
  • 29
  • 49
narancs
  • 5,152
  • 4
  • 37
  • 59

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,283
  • 5
  • 37
  • 60
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,511
  • 19
  • 30