Search code examples
javaintegerdoublestring-parsing

String value = 4.30000000e+01 how to parseInt?


String value = 4.30000000e+01;

how to parseInt?? in java

I already tried using parseInt(value, 10).. in fact, javascript parseInt can convert but java method cause error

how can i solve?


Solution

  • Integers are not supposed to be represented like this. Eventually, you can parse it as a BigDecimal then take its int value :

    int i = new BigDecimal("4.30000000e+01").intValue();