I have a problem in converting java.time.Instant to java.util.Date:
System.out.println(item.getStart()); // getStart returns instant
System.out.println(Date.from(item.getStart()));
gives output:
2017-08-29T00:00:00Z
Tue Aug 29 02:00:00 CEST 2017
Why in date time is 02:00:00? And how to do convertion with time 00:00:00
In
2017-08-29T00:00:00Z
theZ
meansZulu
, which meansUTC+0
. So it describtes exactly the same moment in time asTue Aug 29 02:00:00 CEST 2017
which isUTC+2
It gets printed as CEST because the default implementation of the
toString()
method is using the default time zone.You could try using Java8
LocalDate
instead. It hasn’t got any time-of-day information.How to do the conversion you can see here: https://stackoverflow.com/a/35187046/1199731