From ff1209f00f4e3c0f2d55dc24ccf20da625ca4e61 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Tue, 31 Aug 2021 10:57:30 -0400 Subject: [PATCH] Inline duplicate constants. --- .../commons/lang3/time/FastDateParserTest.java | 15 +++++++-------- .../commons/lang3/time/FastDatePrinterTest.java | 3 +-- .../lang3/time/Java15BugFastDateParserTest.java | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java index d7752a58e..e548d2c26 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -54,7 +54,7 @@ import org.junit.jupiter.params.provider.MethodSource; public class FastDateParserTest { private enum Expected1806 { - India(INDIA, "+05", "+0530", "+05:30", true), Greenwich(GMT, "Z", "Z", "Z", false), + India(INDIA, "+05", "+0530", "+05:30", true), Greenwich(TimeZones.GMT, "Z", "Z", "Z", false), NewYork(NEW_YORK, "-05", "-0500", "-05:00", false); final TimeZone zone; @@ -90,7 +90,6 @@ public class FastDateParserTest { private static final TimeZone REYKJAVIK = TimeZone.getTimeZone("Atlantic/Reykjavik"); private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York"); - static final TimeZone GMT = TimeZones.GMT; private static final TimeZone INDIA = TimeZone.getTimeZone("Asia/Calcutta"); private static final Locale SWEDEN = new Locale("sv", "SE"); @@ -320,7 +319,7 @@ public class FastDateParserTest { @Test public void testJpLocales() throws ParseException { - final Calendar cal = Calendar.getInstance(GMT); + final Calendar cal = Calendar.getInstance(TimeZones.GMT); cal.clear(); cal.set(2003, Calendar.FEBRUARY, 10); cal.set(Calendar.ERA, GregorianCalendar.BC); @@ -376,11 +375,11 @@ public class FastDateParserTest { @ParameterizedTest @MethodSource(DATE_PARSER_PARAMETERS) public void testLang1380(final TriFunction dpProvider) throws ParseException { - final Calendar expected = Calendar.getInstance(GMT, Locale.FRANCE); + final Calendar expected = Calendar.getInstance(TimeZones.GMT, Locale.FRANCE); expected.clear(); expected.set(2014, Calendar.APRIL, 14); - final DateParser fdp = getInstance(dpProvider, "dd MMM yyyy", GMT, Locale.FRANCE); + final DateParser fdp = getInstance(dpProvider, "dd MMM yyyy", TimeZones.GMT, Locale.FRANCE); assertEquals(expected.getTime(), fdp.parse("14 avril 2014")); assertEquals(expected.getTime(), fdp.parse("14 avr. 2014")); assertEquals(expected.getTime(), fdp.parse("14 avr 2014")); @@ -400,7 +399,7 @@ public class FastDateParserTest { @Test public void testLang538() throws ParseException { - final DateParser parser = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", GMT); + final DateParser parser = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZones.GMT); final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-8")); cal.clear(); @@ -514,7 +513,7 @@ public class FastDateParserTest { public void testParses() throws Exception { for (final String format : new String[] {LONG_FORMAT, SHORT_FORMAT}) { for (final Locale locale : Locale.getAvailableLocales()) { - for (final TimeZone timeZone : new TimeZone[] {NEW_YORK, REYKJAVIK, GMT}) { + for (final TimeZone timeZone : new TimeZone[] {NEW_YORK, REYKJAVIK, TimeZones.GMT}) { for (final int year : new int[] {2003, 1940, 1868, 1867, 1, -1, -1940}) { final Calendar cal = getEraStart(year, timeZone, locale); final Date centuryStart = cal.getTime(); @@ -691,7 +690,7 @@ public class FastDateParserTest { for (final Locale locale : Locale.getAvailableLocales()) { final FastDateParser fdp = new FastDateParser("yyyy/MM/dd z", TimeZone.getDefault(), locale); - for (final TimeZone timeZone : new TimeZone[] {NEW_YORK, REYKJAVIK, GMT}) { + for (final TimeZone timeZone : new TimeZone[] {NEW_YORK, REYKJAVIK, TimeZones.GMT}) { final Calendar cal = Calendar.getInstance(timeZone, locale); cal.clear(); cal.set(Calendar.YEAR, 2000); diff --git a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java index 6ef333a5e..772973e1a 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java @@ -43,7 +43,7 @@ import org.junitpioneer.jupiter.DefaultTimeZone; public class FastDatePrinterTest { private enum Expected1806 { - India(INDIA, "+05", "+0530", "+05:30"), Greenwich(GMT, "Z", "Z", "Z"), NewYork( + India(INDIA, "+05", "+0530", "+05:30"), Greenwich(TimeZones.GMT, "Z", "Z", "Z"), NewYork( NEW_YORK, "-05", "-0500", "-05:00"); final TimeZone zone; @@ -60,7 +60,6 @@ public class FastDatePrinterTest { } private static final String YYYY_MM_DD = "yyyy/MM/dd"; private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York"); - private static final TimeZone GMT = TimeZones.GMT; private static final TimeZone INDIA = TimeZone.getTimeZone("Asia/Calcutta"); private static final Locale SWEDEN = new Locale("sv", "SE"); diff --git a/src/test/java/org/apache/commons/lang3/time/Java15BugFastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/Java15BugFastDateParserTest.java index 265ca00b8..9ac105a0a 100644 --- a/src/test/java/org/apache/commons/lang3/time/Java15BugFastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/Java15BugFastDateParserTest.java @@ -67,7 +67,7 @@ public class Java15BugFastDateParserTest { private void testLocales(final TriFunction dbProvider, final String format, final boolean eraBC) throws Exception { - final Calendar cal = Calendar.getInstance(FastDateParserTest.GMT); + final Calendar cal = Calendar.getInstance(TimeZones.GMT); cal.clear(); cal.set(2003, Calendar.FEBRUARY, 10); if (eraBC) { @@ -144,7 +144,7 @@ public class Java15BugFastDateParserTest { } private void testSingleLocale(final Locale locale) throws ParseException { - final Calendar cal = Calendar.getInstance(FastDateParserTest.GMT); + final Calendar cal = Calendar.getInstance(TimeZones.GMT); cal.clear(); cal.set(2003, Calendar.FEBRUARY, 10); final SimpleDateFormat sdf = new SimpleDateFormat(FastDateParserTest.LONG_FORMAT, locale);