Android系统。如何让TimeZone看起来像GMT-0X:00?

时间:2012-08-27 13:28:30

标签: android timezone gmt

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

1 个答案:

答案 0 :(得分: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() );