Time consts in Java?

前端 未结 13 632
遇见更好的自我
遇见更好的自我 2020-12-23 15:45

Is there a Java package with all the annoying time constants like milliseconds/seconds/minutes in a minute/hour/day/year? I\'d hate to duplicate something like that.

13条回答
  •  星月不相逢
    2020-12-23 16:16

    If the constants are to be used as Compile-time constants (for example, as an attribute in an annotation), then Apache DateUtils will come in handy.

    import org.apache.commons.lang.time.DateUtils;
    
    DateUtils.MILLIS_PER_SECOND
    DateUtils.MILLIS_PER_MINUTE
    DateUtils.MILLIS_PER_HOUR
    DateUtils.MILLIS_PER_DAY
    

    These are primitive long constants.

提交回复
热议问题