/** * Gets a TimeZone with GMT offsets. A GMT offset must be either 'Z', or 'UTC', or match * <em>(GMT)? hh?(:?mm?)?</em>, where h and m are digits representing hours and minutes. * * @param pattern The GMT offset * @return A TimeZone with offset from GMT or null, if pattern does not match. */ public static TimeZone getGmtTimeZone(final String pattern) { if ("Z".equals(pattern) || "UTC".equals(pattern)) { return GREENWICH; } final Matcher m = GMT_PATTERN.matcher(pattern); if (m.matches()) { final int hours = parseInt(m.group(2)); final int minutes = parseInt(m.group(4)); if (hours == 0 && minutes == 0) { return GREENWICH; } return new GmtTimeZone(parseSign(m.group(1)), hours, minutes); } return null; }
/** * Gets a TimeZone with GMT offsets. A GMT offset must be either 'Z', or 'UTC', or match * <em>(GMT)? hh?(:?mm?)?</em>, where h and m are digits representing hours and minutes. * * @param pattern The GMT offset * @return A TimeZone with offset from GMT or null, if pattern does not match. */ public static TimeZone getGmtTimeZone(final String pattern) { if ("Z".equals(pattern) || "UTC".equals(pattern)) { return GREENWICH; } final Matcher m = GMT_PATTERN.matcher(pattern); if (m.matches()) { final int hours = parseInt(m.group(2)); final int minutes = parseInt(m.group(4)); if (hours == 0 && minutes == 0) { return GREENWICH; } return new GmtTimeZone(parseSign(m.group(1)), hours, minutes); } return null; }
/** * Gets a TimeZone with GMT offsets. A GMT offset must be either 'Z', or 'UTC', or match * <em>(GMT)? hh?(:?mm?)?</em>, where h and m are digits representing hours and minutes. * * @param pattern The GMT offset * @return A TimeZone with offset from GMT or null, if pattern does not match. */ public static TimeZone getGmtTimeZone(final String pattern) { if ("Z".equals(pattern) || "UTC".equals(pattern)) { return GREENWICH; } final Matcher m = GMT_PATTERN.matcher(pattern); if (m.matches()) { final int hours = parseInt(m.group(2)); final int minutes = parseInt(m.group(4)); if (hours == 0 && minutes == 0) { return GREENWICH; } return new GmtTimeZone(parseSign(m.group(1)), hours, minutes); } return null; }
/** * Gets a TimeZone with GMT offsets. A GMT offset must be either 'Z', or 'UTC', or match * <em>(GMT)? hh?(:?mm?)?</em>, where h and m are digits representing hours and minutes. * * @param pattern The GMT offset * @return A TimeZone with offset from GMT or null, if pattern does not match. */ public static TimeZone getGmtTimeZone(final String pattern) { if ("Z".equals(pattern) || "UTC".equals(pattern)) { return GREENWICH; } final Matcher m = GMT_PATTERN.matcher(pattern); if (m.matches()) { final int hours = parseInt(m.group(2)); final int minutes = parseInt(m.group(4)); if (hours == 0 && minutes == 0) { return GREENWICH; } return new GmtTimeZone(parseSign(m.group(1)), hours, minutes); } return null; }