Repository: commons-lang Updated Branches: refs/heads/master 060e66bf9 -> 9a7de3974
Sort members. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/9a7de397 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/9a7de397 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/9a7de397 Branch: refs/heads/master Commit: 9a7de3974d64a5410e577933e141797928adca71 Parents: 060e66b Author: Gary Gregory <ggreg...@apache.org> Authored: Tue Oct 10 12:03:07 2017 -0600 Committer: Gary Gregory <ggreg...@apache.org> Committed: Tue Oct 10 12:03:07 2017 -0600 ---------------------------------------------------------------------- .../apache/commons/lang3/time/FastTimeZone.java | 46 ++++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/9a7de397/src/main/java/org/apache/commons/lang3/time/FastTimeZone.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/time/FastTimeZone.java b/src/main/java/org/apache/commons/lang3/time/FastTimeZone.java index f43b268..f759758 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastTimeZone.java +++ b/src/main/java/org/apache/commons/lang3/time/FastTimeZone.java @@ -27,11 +27,9 @@ import java.util.regex.Pattern; */ public class FastTimeZone { - private static final TimeZone GREENWICH = new GmtTimeZone(false, 0, 0); + private static final Pattern GMT_PATTERN = Pattern.compile("^(?:(?i)GMT)?([+-])?(\\d\\d?)?(:?(\\d\\d?))?$"); - // do not instantiate - private FastTimeZone() { - } + private static final TimeZone GREENWICH = new GmtTimeZone(false, 0, 0); /** * Gets the GMT TimeZone. @@ -42,25 +40,6 @@ public class FastTimeZone { } /** - * Gets a TimeZone, looking first for GMT custom ids, then falling back to Olson ids. - * A GMT custom id can be 'Z', or 'UTC', or has an optional prefix of GMT, - * followed by sign, hours digit(s), optional colon(':'), and optional minutes digits. - * i.e. <em>[GMT] (+|-) Hours [[:] Minutes]</em> - * - * @param id A GMT custom id (or Olson id - * @return A timezone - */ - public static TimeZone getTimeZone(String id) { - TimeZone tz = getGmtTimeZone(id); - if (tz != null) { - return tz; - } - return TimeZone.getTimeZone(id); - } - - private static final Pattern GMT_PATTERN = Pattern.compile("^(?:(?i)GMT)?([+-])?(\\d\\d?)?(:?(\\d\\d?))?$"); - - /** * 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. * @@ -84,6 +63,23 @@ public class FastTimeZone { return null; } + /** + * Gets a TimeZone, looking first for GMT custom ids, then falling back to Olson ids. + * A GMT custom id can be 'Z', or 'UTC', or has an optional prefix of GMT, + * followed by sign, hours digit(s), optional colon(':'), and optional minutes digits. + * i.e. <em>[GMT] (+|-) Hours [[:] Minutes]</em> + * + * @param id A GMT custom id (or Olson id + * @return A timezone + */ + public static TimeZone getTimeZone(String id) { + TimeZone tz = getGmtTimeZone(id); + if (tz != null) { + return tz; + } + return TimeZone.getTimeZone(id); + } + private static int parseInt(String group) { return group != null ? Integer.parseInt(group) : 0; } @@ -92,4 +88,8 @@ public class FastTimeZone { return group != null && group.charAt(0) == '-'; } + // do not instantiate + private FastTimeZone() { + } + }