### Question:
HL7Util { protected static String getTimeZoneOffset(String fullString, Date givenDate) { String timeZoneOffset; int tzPlus = fullString.indexOf('+'); int tzMinus = fullString.indexOf('-'); boolean timeZoneFlag = (tzPlus > 0 || tzMinus > 0); if (timeZoneFlag) { int tzIndex; if (tzPlus > 0) { tzIndex = tzPlus; } else { tzIndex = tzMinus; } timeZoneOffset = fullString.substring(tzIndex); if (timeZoneOffset.length() != 5) { log.error("Invalid timestamp because its too short: " + timeZoneOffset); } } else { Calendar cal = Calendar.getInstance(); cal.setTime(givenDate); timeZoneOffset = new SimpleDateFormat("Z").format(cal.getTime()); } return timeZoneOffset; } private  HL7Util(); static Date parseHL7Timestamp(String s); static Date parseHL7Date(String s); static Date parseHL7Time(String s); static File getHl7ArchivesDirectory(); static final String LOCAL_TIMEZONE_OFFSET; }### Answer:
@Test public void getTimeZoneOffset_shouldReturnTimezoneForGivenDateAndNotTheCurrentDate() throws ParseException { TimeZone originalTimeZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("GMT-05:00")); Assert.assertEquals("-0500", HL7Util.getTimeZoneOffset("197804110615", new SimpleDateFormat("yyyyMMdd") .parse("20091225"))); TimeZone.setDefault(originalTimeZone); }
@Test public void getTimeZoneOffset_shouldReturnTimezoneStringIfExistsInGivenString() { Assert.assertEquals("+1100", HL7Util.getTimeZoneOffset("348934934934+1100", new Date())); }