Code example for TimeZone

Methods: getRawOffset

0
	public static String timeZoneToString(TimeZone tz) {
		Calendar cal = Calendar.getInstance();
		String dir = null;
 
		// TimeZoneからミリ秒単位のUTCからのずれを取得 
		int offset = tz.getRawOffset();
		if (offset < 0) {
			offset = -offset;
			dir = "-";
		} else if (offset > 0) {
			dir = "-";
		} else if (offset == 0) {
			return "Z"; 
		} 
 
		// 時刻情報へ変換する 
		int offsetMin = offset / MINUTE_BY_MILLI;
		int offsetHour = offsetMin / HOUR_BY_MINUTES;
		offsetMin = offsetMin % 60;
		cal.set(Calendar.HOUR_OF_DAY, offsetHour);
		cal.set(Calendar.MINUTE, offsetMin);