我有一个时间戳记如下到我的服务器。如何将时间戳转换为不同的时区
Date date = new Date();
long timestamp = date.getTime();
这是从不同的时区生成的,我只有上面的长整型值。我需要将这个时间转换为不同的时区。我试图按照下面的方式,但它仍然显示当地时间。
// 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);
一旦成功转换了我需要获得该时间的时间戳的时间。这个怎么做?
检查此问题http://stackoverflow.com/questions/6567923/timezone-conversion –
时间戳将相同。时间戳没有任何时区:2016-09:26T12:00 UTC与巴黎2016-09:26T14:00的时间相同。当您将时间戳显示为人类可读的内容时,时区是相关的。 –