Default value for date/time

Stephen Colebourne scolebourne at joda.org
Mon May 7 12:06:37 UTC 2018


There is an implicit desire in adding value types that classes like
`LocalDate` can be treated as value types. But one of the requirements
of value types is that they have a default value. But what should this
be?

For `LocalDate`, possible candidates might be

- LocalDate.of(1970, 1, 1)
- LocalDate.of(1, 1, 1)
- LocalDate.of(2000, 1, 1)
- LocalDate.MIN
- LocalDate.MAX
- LocalDate.now()

But these are all poor choices IMO. Ultimately, dates are not like
numbers - there isn't a meaningful default like zero.

I suppose we'll have to use 1970-01-01 as it is traditional in Java,
but it doesn't really have *meaning*. I'd be interested in hearing if
there are any other choices or views?

(I think this problem of no sensible default value may well occur for
other value types.)

Stephen


More information about the valhalla-dev mailing list