Reputation: 5727
I have to convert java.util.Date to LocalDate. I stole the example from here: Convert java.util.Date to java.time.LocalDate
but noticed something strange.
When I just use new LocalDate()
then I see in debuger:
but when I do:
date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()
then in debuger I see:
so insted of iLocalMillis
there is year
and so on. Which causes problems for me later. Why is that so? Can I have exactly the same details after conversion as in the new LocalDate()
?
Upvotes: 2
Views: 974
Reputation: 328805
The fields in the first snapshot match the internal structure of an org.joda.time.LocalDate
class.
The fields in the second snapshot match the internal structure of a java.time.LocalDate
class.
So you are mixing two different LocalDate
classes in your code.
Upvotes: 6