1

如何输出“GMT -0X:00”(X - 一个数字)”?

4

1 回答 1

4
Calendar cal = Calendar.getInstance(locale);
// or Calendar cal = Calendar.getInstance(timezone);
int zoneOffset = cal.get(Calendar.ZONE_OFFSET);

// eg: "-0700"
String timezoneStr = new SimpleDateFormat("Z").format( cal.getTime() );
于 2012-08-27T13:37:10.433 回答