Converting a String that contains decimal to Long

后端 未结 5 1445
庸人自扰
庸人自扰 2020-12-11 15:00

I have following sample (link to ideone).

long lDurationMillis =  0;
lDurationMillis = Long.parseLong(\"30000.1\");
System.out.print(\"Play Duration:\" + lD         


        
5条回答
  •  醉话见心
    2020-12-11 15:19

    The value 30000.1 is an invalid long value. You could parse the double value first:

    lDurationMillis = (long)Double.parseDouble("30000.1");
    

提交回复
热议问题