I'm trying to convert a java.util.Date
to java.time.LocalDate
:
[java.util.Date instance].toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
However, there is a case when [java.util.Date instance]
has day time of for example: 22:25 and I choose ZoneId like this for example: ZoneId.of("Asia/Singapore")
.
The outcoming LocalDate
will have different day (because that zone adds +6 hrs) as for example Europe/Minsk:
printing java.util.Date: Thu Mar 04 22:25:00 CET 2021
printing converted java.util.Date to java.time.LocalDate with Europe/Minsk: 2021-03-04
printing converted java.util.Date to java.time.LocalDate with Asia/Singapore: 2021-03-05
and I want to preserve same date in the resulting LocalDate
's as in that Date
instance. Some approaches how to solve this? I guess there could be several ways.