-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for times greater than 24:00 #169
Comments
This would be a perfectly sensible addition to ThreTen-Extra. It could be a combination of |
What would you call this type? |
I like |
I tried some experiment with similar idea and found issue: ChronoField#HOUR_OF_DAY has ValueRange.of(0, 23) How should such "ExtendedLocalTime" work when queried for TemporalField HOUR_OF_DAY? Is it safe to return 29 ? It would be nice if it could because one could just reuse DateTimeFormatter.ISO_LOCAL_DATE_TIME and print 2022-12-31T29:10:10 as the formatter uses value of HOUR_OF_DAY. But there is no chance that parsing would work as there is validation on range. And if HOUR_OF_DAY should not return 29 what should be return? 5 ? But then one can print it as 2022-12-31T05:10:10 which is wrong as 2022-12-31T29:10:10 corresponds to LocalDateTime of 2023-01-01T05:10:10 |
I think we have to accept that this isn't the |
Some domains have time-of-day notations greater than 24:00, indicating that although the given time value may occur on the next calendar day, it is still associated with the previous day.
Per Wikipedia:
For instance, 25:30 on 7/1/2020 would represent the same point on the timeline as 1:30 on 7/2/2020. However, within the application context the time is still associated with the previous day (e.g. it would be displayed or billed or whatever with the previous day's data).
From what I can tell, both
java.time
and Threeten-Extra assume a 24-hour clock, and do not store or parse values at or greater than 24:00.Support for this view of time seems a natural fit for ThreeTen Extra.
It would be useful to be able to pass around instances of this type, parse to/from String representation, do temporal operations on it, convert it to standard wall-clock time, etc.
This view of time would be applicable to the various types that use time. For my use case,
LocalTime
,LocalDateTime
,ZonedDateTime
would probably be what I'd need. It looks like it would be applicable toOffsetTime
andOffsetDateTime
as well.I'm not sure what the best way to fit this into the
javax.time
API would be, if it's a whole new set of types analogous to the existingTime
type, or if there's a different way to approach this.Related StackOverflow question
The text was updated successfully, but these errors were encountered: