Get the number of days, weeks, and months, since Epoch in Java

前端 未结 7 759
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 18:05

I\'m trying to get the number of days, weeks, months since Epoch in Java.

The Java Calendar class offers things like calendar.get(GregorianCalendar.DAY_OF_YEAR), or

7条回答
  •  独厮守ぢ
    2020-12-01 18:22

    Date.getTime() - Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.

    You can use this and knowledge of how many milliseconds are in the intervals you care about to do the calculations.

提交回复
热议问题