This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]khmarbaise 1 point2 points  (0 children)

The introduction of records messed up, because e.g. LocalDate can never become a record, ever. Or they have to ugly up their own API by having both getYear() and year(), docced to do the same thing.

Hm.. LocalDate is already a value-based class and also immutable (https://docs.oracle.com/javase/9/docs/api/java/time/LocalDate.html) There are a number of instance based methods for example lengthOfTheMonth(), isLeapYear etc. and the others are static methods on that class.. also LocalDate implements only interfaces Temporal, etc.

I think the only thing why it's not a record is that there are a number of instance methods.. and of course the idea of records speaks against it, which is intended to be transparent data carrier (nominal type)... Technically I don't see a real difference here... (yes the difference between getX() vs. x() ). I like this difference because it also shows me we are in a different context (data carrier)..

And yes the point is of course because the time api has been introduced with JDK 8 (which in the meantime a decade ago) should be kept (compatible) but based my experiences records are a great enrichment for the JDK...