问题还原:
public static void main(String[] args) {
String startTime ="1.626290463E12"; System.out.println("begin================"+Long.parseLong(startTime));
}
报错信息:
Exception in thread "main" java.lang.NumberFormatException: For input string: "1.626290463E12"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
at basis.xz.stringformat.main(stringformat.java:34)
解决:
public static void main(String[] args) { String startTime ="1.626290463E12"; //long类型十进制还原 BigDecimal v = new BigDecimal(startTime).setScale(0,BigDecimal.ROUND_HALF_UP); System.out.println(Long.parseLong(v));
}