我正在使用 Joda Time,并且正在传递使用DateTimeZone.forOffsetHours()
. 我想使用标准时区首字母缩写词(例如“PST”、“EST”等)打印这些时区。
但是,每当我打印使用这些时区的 DateTimes 时,我都会得到时区的“hh:mm”表示,而不是名称的首字母缩写词。
这是一个例子:
public class tmp {
public static void main( String args[] ) {
// "PST"
System.out.println( DateTimeFormat.forPattern("z").print( new DateTime() ) );
// "PST"
System.out.println( DateTimeFormat.forPattern("z").print( new DateTime( DateTimeZone.forTimeZone( TimeZone.getTimeZone("PST")) )) );
// "-08:00"
System.out.println( DateTimeFormat.forPattern("z").print( new DateTime( DateTimeZone.forOffsetHours(-8) )) );
}
}
有没有办法在最后一个示例中使用 Joda Time 打印出适当的时区首字母缩写词?