默认情况下,新用户
SimpleDateFormat将使用系统默认时区。如果您想要一个特定的时区,请致电
setTimeZone:
private final static SimpleDateFormat DATE_FORMAT = createFormat();private static SimpleDateFormat createFormat() { // Make sure there are no locale-specific nasties, either... SimpleDateFormat ret = new SimpleDateFormat("yyyy.MM.dd'T'HH:mm.ss:SSSZZ", Locale.US); ret.setTimeZone(TimeZone.getTimeZone("Etc/UTC");}
对于第二项测试,您想要将其更改为:
new DateTime(0L, DateTimeZone.UTC);
请注意,通常不应该使用静态
SimpleDateFormat变量,因为它不是线程安全的。(而Joda Time
DateTimeFormatter实现 是 线程安全的。)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)