How to convert from Date to LocalDate when using ThreeTenABP?

NOTE. The answer to this question is already excellent in the JDK world here , but the accepted answer does not apply to the Android port JSR-310 , which does not have an extended date API.

So what is the best way to convert java.util.Dateto org.threeten.bp.LocalDate?

Date input = new Date();
LocalDate date = ???
+4
source share
1 answer

That should do it (inspired by fooobar.com/questions/20020 / ... ).

Date dateJavaFormat = new Date();
LocalDate dateThreeTenFormat = Instant.ofEpochMilli(dateJavaFormat.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
+7
source

Source: https://habr.com/ru/post/1598208/


All Articles