I just wonder, why some enums are missing on the TimeUnit class of Java?
Actually the max timeunit is DAY while i would like to use stuff like WEEK, YEAR…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
TimeUnit.DAYSconstant represents an interval of 24 hours, not a calendar day (midnight to midnight). Anything beyond a day (a week, a month, a year) is a calendar unit, not a time unit. The duration of calendar units depends on the calendar in use: for example, a week can be longer or shorter by an hour on weeks when daylight savings time goes in and out of effect, leap years are longer by a day, and so on. That is why including calendar units intoTimeUnitenumeration would not make sense.