I'm trying to convert ZonedDateTime to milliseconds using below code.
LocalDateTime ldt = LocalDateTime.now();
ZonedDateTime zonedDateTime =ldt.atZone(ZoneId.of(""Asia/Kolkata""));
zonedDateTime.toInstant().toEpochMilli();
But this one returns milliseconds based on local time. And it's not considering ZoneId.
Let's say LocalDateTime("2019-04-10T05:30")
. If I convert this to ZonedDateTime
with Zone id ("Asia/Kolkata") then I'm getting ("2019-04-10T05:30+05:30[Asia/Kolkata]"
). Then I convert to EpochMilli (1554854400000) = ("Wed Apr 10 2019 00:00:00"
) in UTC.