似乎JodaTime不支持该功能.如果你试试
org.joda.time.DateTimeZone.forTimeZone(TimeZone.getTimeZone("GMT"))
您实际上以UTC结尾. DateTimeZone中的javadoc指出:
This library only uses the term UTC.
您可能可以自己继承DateTimeZone并获得所需的内容,但是据我所知,JodaTime不会执行您要执行的操作.下面是一个示例,尽管我并不声称它可以以任何形式运行.
public class GMTDTZ extends DateTimeZone {
public GMTDTZ() { super("GMT"); }
@Override public String getNameKey(long instant) { return null; }
@Override public int getOffset(long instant) { return 0; }
@Override public int getStandardOffset(long instant) { return 0; }
@Override public boolean isFixed() { return true;}
@Override public long nextTransition(long instant) { return instant; }
@Override public long previousTransition(long instant) { return instant; }
@Override public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof DateTimeZone)) return false;
return (((DateTimeZone) o).getID().equals("GMT"));
}
}