Converting exponential value in java to a number format

前端 未结 12 1499
旧巷少年郎
旧巷少年郎 2020-12-06 05:47

I am trying to read the values from excel sheet using java. When i type more than 10 letters in a cell in excel it is displaying in exponential form like \"9.78313E+2\". but

12条回答
  •  被撕碎了的回忆
    2020-12-06 06:19

    You can convert easily with the following methods:

    Double.valueOf("9.78313E+2").longValue() or

    BigDecimal bd = new BigDecimal("9.78313E+2");
    long val = bd.longValue();
    

    Assuming that the given number is in a String form.

提交回复
热议问题