I have a timestamp taken as below coming to my server.
Date date = new Date();
long timestamp = date.getTime();
This is generated from different timezone and I only have the above long value. I need to convert this time to different timezone. I tried following way but still it shows the local time.
// Convert to localdatetime using local time zone
LocalDateTime ldt = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp),
ZoneId.systemDefault());
// Convert time to required time zone.
ZoneId est5EDT = ZoneId.of("EST5EDT");
ZonedDateTime est5EDTTime = ldt.atZone(est5EDT);
System.out.println("EST5EDT : " + est5EDTTime);
Once successfully converted the time I need to get timestamp of that time. How to do this?