OffsetDate represents a date with a zone offset. I don't understand the purpose this class serves, what are the main use cases justifying its existence?
Instant is the simplest, simply representing the instant. OffsetDateTime adds to the instant the offset from UTC/Greenwich, which allows the local date-time to be obtained. ZonedDateTime adds full time-zone rules. It is intended that ZonedDateTime or Instant is used to model data in simpler applications.
It obtains an instance of OffsetDateTime from a text string such as 2007-12-03T10:15:30. It gets the range of valid values for the specified field. It converts this date-time to the number of seconds from the epoch of 1970-01-01T00:00:00Z. It returns a copy of this OffsetDateTime with the time truncated.
The project has been led jointly by the author of Joda-Time (Stephen Colebourne) and Oracle, under JSR 310, and will appear in the new Java SE 8 package java. time .
When analysing the basic components of dates and times there are four basic elements:
These naturaly form seven classes:
(a time-zone can only be used if you know the date and the time, so there is no ZonedDate or ZonedTime class)
The first six forms directly match XML schema definitions, which in effect justifies their existence. In application design terms I suspect that OffsetDate
will be the least used of the seven classes.
Update: 2013-01-24: OffsetDate won't be in JDK 1.8.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With