티스토리 뷰

public static String getTimeZone() {

        TimeZone timeZone = TimeZone.getDefault();
        Calendar calendar = GregorianCalendar.getInstance(timeZone);
        int offsetInMillis = timeZone.getOffset(calendar.getTimeInMillis());

        Log.v("gmt offset(sec)", String.valueOf(offsetInMillis));

        //초에서 분으로 환산
        String offset = String.format(Locale.getDefault(),"%02d",
                Math.abs((offsetInMillis / 60000)));
        Log.v("gmt offset(min)", offset);
        offset = (offsetInMillis >= 0 ? "+" : "-") + offset;

        String strGmt = timeZone.getDisplayName(false,TimeZone.SHORT);
        String strId = timeZone.getID();

        String strTimeZone = String.format("Local;%s;(%s) Local Time;%s;", offset, strGmt, strId);

        return strTimeZone;
}

output

gmt offset(sec): 32400000
gmt offset(min): 540
Local;+540;(GMT+09:00) Local Time;Asia/Seoul;
댓글