使用java.util.TimeZone查找DST转换时间戳 [英] Find DST transition timestamp with java.util.TimeZone

查看:64
本文介绍了使用java.util.TimeZone查找DST转换时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Java Calendar/Date/TimeZone API获取上一个和下一个DST转换时间戳?
使用Joda-Time,我可以写:

Is it possible to get the previous and next DST transition timestamp with the Java Calendar/Date/TimeZone API?
With Joda-Time I can write:

DateMidnight today = new DateMidnight(2009, 2, 24);
DateTimeZone zone = today.getZone();

DateTime previousTransition =
    new DateTime(zone.previousTransition(today.getMillis()));
// 2008-10-26T02:59:59.999+02:00 for Europe/Berlin
System.out.println(previousTransition);

DateTime nextTransition =
    new DateTime(zone.nextTransition(today.getMillis()));
// 2009-03-29T03:00:00.000+02:00 for Europe/Berlin
System.out.println(nextTransition);

是否可以使用标准Java API做到这一点?

Is there way to do this with the standard Java APIs?

推荐答案

java Date/Calendar/TimeZone API中没有此类功能

There's no such functionality in java Date/Calendar/TimeZone API

这篇关于使用java.util.TimeZone查找DST转换时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆