What are the use cases justifying the 310 OffsetDate type?

1.1k views Asked by At

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?

1

There are 1 answers

9
JodaStephen On BEST ANSWER

When analysing the basic components of dates and times there are four basic elements:

  • date
  • time
  • offset (hours plus/minus from Greenwich)
  • time-zone

These naturaly form seven classes:

  • LocalDate - date only
  • LocalTime - time only
  • LocalDateTime - date + time
  • OffsetDate - date + offset
  • OffsetTime - time + offset
  • OffsetDateTime - date + time + offset
  • ZonedDateTime - date + time + offset + zone

(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.