### Question:
DaylightOffsetCalculator { static long getDSTOffset(final TimeZone tz, final Date beginDate, final Date endDate) { if (tz.inDaylightTime(beginDate) && !tz.inDaylightTime(endDate)) { final Calendar cal = Calendar.getInstance(tz); cal.setTime(beginDate); return cal.get(Calendar.DST_OFFSET); } if (!tz.inDaylightTime(beginDate) && tz.inDaylightTime(endDate)) { final Calendar cal = Calendar.getInstance(tz); cal.setTime(endDate); return -cal.get(Calendar.DST_OFFSET); } return 0; } DaylightOffsetCalculator(final Date startMatdTime, final Date endMatdTime);   }### Answer:
@Test public void testGetDSTOffsetOfNonDaylightChangeGivesZeroOffset() throws ParseException { final long dstOffset = DaylightOffsetCalculator.getDSTOffset(TZ_DST, DateUtils.parseDateOozieTZ("2013-07-18T00:00Z"), DateUtils.parseDateOozieTZ("2013-07-19T00:00Z")); assertEquals("non-daylight change should give zero DST offset", 0L, dstOffset); }
@Test public void testGetDSTOffsetOfDaylightChangeFromDSTToStandardGivesPositiveOffset() throws ParseException { final long dstOffset = DaylightOffsetCalculator.getDSTOffset(TZ_DST, DateUtils.parseDateOozieTZ("2013-07-18T00:00Z"), DateUtils.parseDateOozieTZ("2014-01-19T00:00Z")); assertEquals("daylight change from DST to standard should give positive DST offset", 3_600_000L, dstOffset); }
@Test public void testGetDSTOffsetOfDaylightChangeFromStandardToDSTGivesNegativeOffset() throws ParseException { final long dstOffset = DaylightOffsetCalculator.getDSTOffset(TZ_DST, DateUtils.parseDateOozieTZ("2013-01-18T00:00Z"), DateUtils.parseDateOozieTZ("2013-07-19T00:00Z")); assertEquals("daylight change from standard to DST should give negative DST offset", -3_600_000L, dstOffset); }
@Test public void testGetDSTOffsetGivenStandardTZGivesZeroOffset() throws ParseException { final long dstOffset = DaylightOffsetCalculator.getDSTOffset(TZ_STANDARD, DateUtils.parseDateOozieTZ("2013-01-18T00:00Z"), DateUtils.parseDateOozieTZ("2013-07-19T00:00Z")); assertEquals("daylight change from standard to DST should give negative DST offset", 0L, dstOffset); }