首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Joda-time 施用

2012-10-25 
Joda-time 使用JDK InteroperabilityThe?DateTime?class has a constructor which takes an?Object?as inp

Joda-time 使用

JDK Interoperability

The?DateTime?class has a constructor which takes an?Object?as input. In particular this constructor can be passed a JDK?Date, JDK?Calendar?or JDK?GregorianCalendar?(It also accepts an ISO8601 formatted String, or?Long?object representing milliseconds). This is one half of the interoperability with the JDK. The other half of interoperability with JDK is provided by?DateTime?methods which return JDK objects.

Thus inter-conversion between Joda?DateTime?and JDK?Date?can be performed as follows

    // get current moment in default time zone    DateTime dt = new DateTime();    // find the moment when London will have / had the same time    dtLondonSameTime = dt.withZoneRetainFields(DateTimeZone.forID("Europe/London"));

A set of all TimeZone ID strings (such as "Europe/London") may be obtained by calling?DateTimeZone.getAvailableIDs(). A full list of available time zones is provided?here.

?

?

热点排行