Repository: commons-lang Updated Branches: refs/heads/master 448549121 -> fd60085a2
Refactor "GMT" magic string. Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/fd60085a Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/fd60085a Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/fd60085a Branch: refs/heads/master Commit: fd60085a2a3891ab6db46dd3b75e9dd67a7c734a Parents: 4485491 Author: Gary Gregory <[email protected]> Authored: Mon Oct 9 14:40:43 2017 -0600 Committer: Gary Gregory <[email protected]> Committed: Mon Oct 9 14:40:43 2017 -0600 ---------------------------------------------------------------------- .../commons/lang3/time/FastDateParser.java | 6 ++-- .../apache/commons/lang3/time/TimeZones.java | 31 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/fd60085a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java index 8511bba..23abc5a 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java @@ -844,7 +844,7 @@ public class FastDateParser implements DateParser, Serializable { for (final String[] zoneNames : zones) { // offset 0 is the time zone ID and is not localized final String tzId = zoneNames[ID]; - if (tzId.equalsIgnoreCase("GMT")) { + if (tzId.equalsIgnoreCase(TimeZones.GMT_ID)) { continue; } final TimeZone tz = TimeZone.getTimeZone(tzId); @@ -889,9 +889,9 @@ public class FastDateParser implements DateParser, Serializable { @Override void setCalendar(final FastDateParser parser, final Calendar cal, final String timeZone) { if (timeZone.charAt(0) == '+' || timeZone.charAt(0) == '-') { - final TimeZone tz = TimeZone.getTimeZone("GMT" + timeZone); + final TimeZone tz = TimeZone.getTimeZone(TimeZones.GMT_ID + timeZone); cal.setTimeZone(tz); - } else if (timeZone.regionMatches(true, 0, "GMT", 0, 3)) { + } else if (timeZone.regionMatches(true, 0, TimeZones.GMT_ID, 0, 3)) { final TimeZone tz = TimeZone.getTimeZone(timeZone.toUpperCase(Locale.ROOT)); cal.setTimeZone(tz); } else { http://git-wip-us.apache.org/repos/asf/commons-lang/blob/fd60085a/src/main/java/org/apache/commons/lang3/time/TimeZones.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/time/TimeZones.java b/src/main/java/org/apache/commons/lang3/time/TimeZones.java new file mode 100644 index 0000000..634a9e3 --- /dev/null +++ b/src/main/java/org/apache/commons/lang3/time/TimeZones.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.lang3.time; + +/** + * Helps to deal with {@link java.util.TimeZone}s. + * + * @since 3.7 + */ +public class TimeZones { + + /** + * A public version of {@link java.util.TimeZone}'s package private {@code GMT_ID} field. + */ + public static final String GMT_ID = "GMT"; +}
