@Test public void testTnefTimeZoneFromIntIndex() throws IOException { TimeZone tz = null; tz = TnefTimeZone.getTimeZone(13, true, null); Assert.assertFalse(tz == null); Assert.assertTrue(tz.getRawOffset() == -28800000); Assert.assertTrue(tz.getDSTSavings() == 3600000); tz = TnefTimeZone.getTimeZone(31, true, null); Assert.assertFalse(tz == null); Assert.assertTrue(tz.getRawOffset() == 0); Assert.assertTrue(tz.getDSTSavings() == 0); tz = TnefTimeZone.getTimeZone(60, true, null); Assert.assertTrue(tz == null); tz = TnefTimeZone.getTimeZone(24, false, null); Assert.assertFalse(tz == null); Assert.assertTrue(tz.getID().equals("Asia/Dubai")); }
public static TimeZone getTimeZone(int index, boolean observeDaylightSaving, String tzId) throws IOException { if (index < 0 || index > 59) return null; int bias = 0; int standardBias = 0; int daylightBias = 0; SYSTEMTIME StandardDate = null; SYSTEMTIME DaylightDate = null; int startMonth = 0; int startDayOfWeek = 0; int startDay = 0; int startHour = 0; int endMonth = 0; int endDayOfWeek = 0; int endDay = 0; int endHour = 0; int utcPlus12offset = MS_OXOCAL_STANDARD_OFFSET[index][0]; int indexToDaytimeSavingDatesTable = MS_OXOCAL_STANDARD_OFFSET[index][1]; if (utcPlus12offset > 12*60) bias = (utcPlus12offset - 12*60) * -1; else if (utcPlus12offset < 12*60) bias = (12*60 - utcPlus12offset); if (indexToDaytimeSavingDatesTable == -1 || !observeDaylightSaving) { int utcOffsetInMilliseconds = bias * 60 * 1000; return getNoDaylightSavingTimeZoneFromUtcOffset(utcOffsetInMilliseconds); } bias = bias * -1; daylightBias = -60; startMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][0]; startDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][1]; startDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][2]; startHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][3]; endMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][0]; endDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][1]; endDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][2]; endHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][3]; StandardDate = new SYSTEMTIME(endMonth, endDayOfWeek, endDay, endHour); DaylightDate = new SYSTEMTIME(startMonth, startDayOfWeek, startDay, startHour); if (sLog.isDebugEnabled()) { StringBuilder debugInfo = new StringBuilder(); debugInfo.append(bias * -1 + " " + "{" + endMonth + "," + endDayOfWeek + "," + endDay + "," + endHour + "} " + "{" + startMonth + "," + startDayOfWeek + "," + startDay + "," + startHour + "}"); sLog.debug(debugInfo); } String timeZoneId; if (tzId == null || tzId.length() == 0) timeZoneId = DEFAULT_TNEF_TIMEZONE_ID; else timeZoneId = tzId; TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(timeZoneId, bias, standardBias, daylightBias, StandardDate, DaylightDate); return timeZoneDefinition.getTimeZone(); }
TnefTimeZone { public static TimeZone getTimeZone(int index, boolean observeDaylightSaving, String tzId) throws IOException { if (index < 0 || index > 59) return null; int bias = 0; int standardBias = 0; int daylightBias = 0; SYSTEMTIME StandardDate = null; SYSTEMTIME DaylightDate = null; int startMonth = 0; int startDayOfWeek = 0; int startDay = 0; int startHour = 0; int endMonth = 0; int endDayOfWeek = 0; int endDay = 0; int endHour = 0; int utcPlus12offset = MS_OXOCAL_STANDARD_OFFSET[index][0]; int indexToDaytimeSavingDatesTable = MS_OXOCAL_STANDARD_OFFSET[index][1]; if (utcPlus12offset > 12*60) bias = (utcPlus12offset - 12*60) * -1; else if (utcPlus12offset < 12*60) bias = (12*60 - utcPlus12offset); if (indexToDaytimeSavingDatesTable == -1 || !observeDaylightSaving) { int utcOffsetInMilliseconds = bias * 60 * 1000; return getNoDaylightSavingTimeZoneFromUtcOffset(utcOffsetInMilliseconds); } bias = bias * -1; daylightBias = -60; startMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][0]; startDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][1]; startDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][2]; startHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][3]; endMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][0]; endDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][1]; endDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][2]; endHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][3]; StandardDate = new SYSTEMTIME(endMonth, endDayOfWeek, endDay, endHour); DaylightDate = new SYSTEMTIME(startMonth, startDayOfWeek, startDay, startHour); if (sLog.isDebugEnabled()) { StringBuilder debugInfo = new StringBuilder(); debugInfo.append(bias * -1 + " " + "{" + endMonth + "," + endDayOfWeek + "," + endDay + "," + endHour + "} " + "{" + startMonth + "," + startDayOfWeek + "," + startDay + "," + startHour + "}"); sLog.debug(debugInfo); } String timeZoneId; if (tzId == null || tzId.length() == 0) timeZoneId = DEFAULT_TNEF_TIMEZONE_ID; else timeZoneId = tzId; TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(timeZoneId, bias, standardBias, daylightBias, StandardDate, DaylightDate); return timeZoneDefinition.getTimeZone(); } }
TnefTimeZone { public static TimeZone getTimeZone(int index, boolean observeDaylightSaving, String tzId) throws IOException { if (index < 0 || index > 59) return null; int bias = 0; int standardBias = 0; int daylightBias = 0; SYSTEMTIME StandardDate = null; SYSTEMTIME DaylightDate = null; int startMonth = 0; int startDayOfWeek = 0; int startDay = 0; int startHour = 0; int endMonth = 0; int endDayOfWeek = 0; int endDay = 0; int endHour = 0; int utcPlus12offset = MS_OXOCAL_STANDARD_OFFSET[index][0]; int indexToDaytimeSavingDatesTable = MS_OXOCAL_STANDARD_OFFSET[index][1]; if (utcPlus12offset > 12*60) bias = (utcPlus12offset - 12*60) * -1; else if (utcPlus12offset < 12*60) bias = (12*60 - utcPlus12offset); if (indexToDaytimeSavingDatesTable == -1 || !observeDaylightSaving) { int utcOffsetInMilliseconds = bias * 60 * 1000; return getNoDaylightSavingTimeZoneFromUtcOffset(utcOffsetInMilliseconds); } bias = bias * -1; daylightBias = -60; startMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][0]; startDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][1]; startDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][2]; startHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][3]; endMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][0]; endDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][1]; endDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][2]; endHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][3]; StandardDate = new SYSTEMTIME(endMonth, endDayOfWeek, endDay, endHour); DaylightDate = new SYSTEMTIME(startMonth, startDayOfWeek, startDay, startHour); if (sLog.isDebugEnabled()) { StringBuilder debugInfo = new StringBuilder(); debugInfo.append(bias * -1 + " " + "{" + endMonth + "," + endDayOfWeek + "," + endDay + "," + endHour + "} " + "{" + startMonth + "," + startDayOfWeek + "," + startDay + "," + startHour + "}"); sLog.debug(debugInfo); } String timeZoneId; if (tzId == null || tzId.length() == 0) timeZoneId = DEFAULT_TNEF_TIMEZONE_ID; else timeZoneId = tzId; TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(timeZoneId, bias, standardBias, daylightBias, StandardDate, DaylightDate); return timeZoneDefinition.getTimeZone(); }  }
TnefTimeZone { public static TimeZone getTimeZone(int index, boolean observeDaylightSaving, String tzId) throws IOException { if (index < 0 || index > 59) return null; int bias = 0; int standardBias = 0; int daylightBias = 0; SYSTEMTIME StandardDate = null; SYSTEMTIME DaylightDate = null; int startMonth = 0; int startDayOfWeek = 0; int startDay = 0; int startHour = 0; int endMonth = 0; int endDayOfWeek = 0; int endDay = 0; int endHour = 0; int utcPlus12offset = MS_OXOCAL_STANDARD_OFFSET[index][0]; int indexToDaytimeSavingDatesTable = MS_OXOCAL_STANDARD_OFFSET[index][1]; if (utcPlus12offset > 12*60) bias = (utcPlus12offset - 12*60) * -1; else if (utcPlus12offset < 12*60) bias = (12*60 - utcPlus12offset); if (indexToDaytimeSavingDatesTable == -1 || !observeDaylightSaving) { int utcOffsetInMilliseconds = bias * 60 * 1000; return getNoDaylightSavingTimeZoneFromUtcOffset(utcOffsetInMilliseconds); } bias = bias * -1; daylightBias = -60; startMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][0]; startDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][1]; startDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][2]; startHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][3]; endMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][0]; endDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][1]; endDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][2]; endHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][3]; StandardDate = new SYSTEMTIME(endMonth, endDayOfWeek, endDay, endHour); DaylightDate = new SYSTEMTIME(startMonth, startDayOfWeek, startDay, startHour); if (sLog.isDebugEnabled()) { StringBuilder debugInfo = new StringBuilder(); debugInfo.append(bias * -1 + " " + "{" + endMonth + "," + endDayOfWeek + "," + endDay + "," + endHour + "} " + "{" + startMonth + "," + startDayOfWeek + "," + startDay + "," + startHour + "}"); sLog.debug(debugInfo); } String timeZoneId; if (tzId == null || tzId.length() == 0) timeZoneId = DEFAULT_TNEF_TIMEZONE_ID; else timeZoneId = tzId; TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(timeZoneId, bias, standardBias, daylightBias, StandardDate, DaylightDate); return timeZoneDefinition.getTimeZone(); }  static TimeZone getTimeZone(int index, boolean observeDaylightSaving, String tzId); static TimeZone getTimeZone(RawInputStream ris); static TimeZone getTimeZone(RawInputStream ris, String tzId); }
TnefTimeZone { public static TimeZone getTimeZone(int index, boolean observeDaylightSaving, String tzId) throws IOException { if (index < 0 || index > 59) return null; int bias = 0; int standardBias = 0; int daylightBias = 0; SYSTEMTIME StandardDate = null; SYSTEMTIME DaylightDate = null; int startMonth = 0; int startDayOfWeek = 0; int startDay = 0; int startHour = 0; int endMonth = 0; int endDayOfWeek = 0; int endDay = 0; int endHour = 0; int utcPlus12offset = MS_OXOCAL_STANDARD_OFFSET[index][0]; int indexToDaytimeSavingDatesTable = MS_OXOCAL_STANDARD_OFFSET[index][1]; if (utcPlus12offset > 12*60) bias = (utcPlus12offset - 12*60) * -1; else if (utcPlus12offset < 12*60) bias = (12*60 - utcPlus12offset); if (indexToDaytimeSavingDatesTable == -1 || !observeDaylightSaving) { int utcOffsetInMilliseconds = bias * 60 * 1000; return getNoDaylightSavingTimeZoneFromUtcOffset(utcOffsetInMilliseconds); } bias = bias * -1; daylightBias = -60; startMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][0]; startDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][1]; startDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][2]; startHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][1][3]; endMonth = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][0]; endDayOfWeek = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][1]; endDay = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][2]; endHour = MS_OXOCAL_STAN_DST_DATES[indexToDaytimeSavingDatesTable][0][3]; StandardDate = new SYSTEMTIME(endMonth, endDayOfWeek, endDay, endHour); DaylightDate = new SYSTEMTIME(startMonth, startDayOfWeek, startDay, startHour); if (sLog.isDebugEnabled()) { StringBuilder debugInfo = new StringBuilder(); debugInfo.append(bias * -1 + " " + "{" + endMonth + "," + endDayOfWeek + "," + endDay + "," + endHour + "} " + "{" + startMonth + "," + startDayOfWeek + "," + startDay + "," + startHour + "}"); sLog.debug(debugInfo); } String timeZoneId; if (tzId == null || tzId.length() == 0) timeZoneId = DEFAULT_TNEF_TIMEZONE_ID; else timeZoneId = tzId; TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(timeZoneId, bias, standardBias, daylightBias, StandardDate, DaylightDate); return timeZoneDefinition.getTimeZone(); }  static TimeZone getTimeZone(int index, boolean observeDaylightSaving, String tzId); static TimeZone getTimeZone(RawInputStream ris); static TimeZone getTimeZone(RawInputStream ris, String tzId); static final String DEFAULT_TNEF_TIMEZONE_ID; }