大家好,又见面了,我是你们的朋友全栈君。
今天想定义一个类常量,结果如下面那样定义,确报错了。
error is: Integer number too large
public static final Long STARTTIME = 1493568000000;
- 1
- 2
我就去查了下,在后面加上L,就好了,就会作为long类型来处理了,若是不加,则作为int处理,而int是没有这么大的值的。
正确的则是
public static final Long STARTTIME = 1493568000000L;
注意: System.currentTimeMillis() 单位毫秒
System.nanoTime() 单位纳秒
1ms=10^6 ns
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/160115.html原文链接:https://javaforall.net