Converting a String that contains decimal to Long

后端 未结 5 1435
庸人自扰
庸人自扰 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:39

    Because long can't have fractional part, you could convert it to double and then cast it to long ignoring fractional part

提交回复
热议问题