NOTE: This is answered already excellently in the JDK world here , but the accepted answer doesn't apply to the Android port of JSR-310 which doesn't have that extended API for Date.
So, what is the best way to convert a java.util.Date
to org.threeten.bp.LocalDate
?
Date input = new Date();
LocalDate date = ???
This should do it (inspired by https://stackoverflow.com/a/27378709/286419 ).
Date dateJavaFormat = new Date();
LocalDate dateThreeTenFormat = Instant.ofEpochMilli(dateJavaFormat.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.