Thanks - I didn't know Java 8 had incorporated Joda time.
Actually LocalDate is a better representation for Type 2 because it doesn't encapsulate minutes, hours or seconds. This would make it ideal to represent "John's birthday" or "date on which the customer repaid loan".
In fact, I'm disappointed that Java has incorporated Joda time - new Java programmers will now need to crawl over a huge pile of time-based classes to pick out the ones they need, when for 99% of cases only the same 3 types are necessary. How many of these novice users will incorrectly use LocalDateTime to represent Type 1?
To be fair, they didn't literally incorporate Joda, the new library is "heavily inspired" by it. It has way fewer classes, organized into a very sensibly named hierarchy.
Yes, but the java.time package is significantly smaller, and much improved in my opinion. For example, Joda has a few mutable structures, while java.time is 100% immutable.
I still don't like how you can do things like Instant.from(DayOfWeek.MONDAY) (which results in a runtime exception), but at least at least it's slightly more type-safe than Joda, wherein all the conversion methods take an Object parameter.
Actually LocalDate is a better representation for Type 2 because it doesn't encapsulate minutes, hours or seconds. This would make it ideal to represent "John's birthday" or "date on which the customer repaid loan".
In fact, I'm disappointed that Java has incorporated Joda time - new Java programmers will now need to crawl over a huge pile of time-based classes to pick out the ones they need, when for 99% of cases only the same 3 types are necessary. How many of these novice users will incorrectly use LocalDateTime to represent Type 1?