Java Milliseconds in Year

前端 未结 9 1906
终归单人心
终归单人心 2020-12-09 08:24

I am doing some date calculations in Java using milliseconds and noticing an issue with the following:

private static final int MILLIS_IN_SECOND = 1000;
             


        
9条回答
  •  天命终不由人
    2020-12-09 09:06

    To fix this, you can put the letter L after the first one: e.g. 1000L

    long MILLS_IN_YEAR = 1000L * 60 * 60 * 24 * 365; // Returns 31536000000
    

提交回复
热议问题