开发者

Java date handling: store date, time and timezone in a single class

开发者 https://www.devze.com 2023-01-08 05:38 出处:网络
Does there exist a Java class, either in the standard libraries or third party, that allows one to store the date, time in millisecond accuracy and the timezone of the time within the same object?

Does there exist a Java class, either in the standard libraries or third party, that allows one to store the date, time in millisecond accuracy and the timezone of the time within the same object?

The features I need:

  • Store a date, time with at least millisecond accuracy and the timezone
  • Parse string date representations (e.g. "2010-07-20T13:22:59.043+0300")
  • Convert the time to system local timezone for display purposes
  • Create a string representation of the date and time
  • Create an object representing the system's current time with the correct timezone information (as provided by the operating system)

What are my options, please? All of the features need not to be stuffed into a single class, but the simpler t开发者_如何学Gohe better.


I've heard good things about the Joda Time library, it seems to have a class to fit your needs:

org.joda.time.DateTime

http://joda-time.sourceforge.net/api-release/index.html

0

精彩评论

暂无评论...
验证码 换一张
取 消