Convert java.util.Date to LocalDate

Michu93 :

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: enter image description here

but when I do: date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate() then in debuger I see: enter image description here

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()?

assylias :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=117870&siteId=1