diff --git a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java index 3b0d11fa4..b0a6b5dd2 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java @@ -16,9 +16,10 @@ */ package org.apache.commons.lang3.time; -import org.junit.Test; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; @@ -27,6 +28,8 @@ import java.util.Date; import java.util.Locale; import java.util.TimeZone; +import org.junit.Test; + /** * TestCase for DateFormatUtils. * @@ -48,7 +51,7 @@ public class DateFormatUtilsTest { @Test public void testFormat() { final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - c.set(2005,0,1,12,0,0); + c.set(2005, Calendar.JANUARY, 1, 12, 0, 0); c.setTimeZone(TimeZone.getDefault()); final StringBuilder buffer = new StringBuilder (); final int year = c.get(Calendar.YEAR); @@ -72,7 +75,7 @@ public class DateFormatUtilsTest { @Test public void testFormatCalendar() { final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - c.set(2005,0,1,12,0,0); + c.set(2005, Calendar.JANUARY, 1, 12, 0, 0); c.setTimeZone(TimeZone.getDefault()); final StringBuilder buffer = new StringBuilder (); final int year = c.get(Calendar.YEAR); @@ -95,7 +98,7 @@ public class DateFormatUtilsTest { @Test public void testFormatUTC() { final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - c.set(2005,0,1,12,0,0); + c.set(2005, Calendar.JANUARY, 1, 12, 0, 0); assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern())); assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern())); @@ -109,7 +112,7 @@ public class DateFormatUtilsTest { public void testDateTimeISO() throws Exception { final TimeZone timeZone = TimeZone.getTimeZone("GMT-3"); final Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23,9,11,12); + cal.set(2002, Calendar.FEBRUARY, 23, 9, 11, 12); String text = DateFormatUtils.format(cal.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), timeZone); assertEquals("2002-02-23T09:11:12", text); @@ -129,7 +132,7 @@ public class DateFormatUtilsTest { assertEquals("2002-02-23T09:11:12-03:00", text); Calendar utcCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - utcCal.set(2002, 1, 23, 9, 11, 12); + utcCal.set(2002, Calendar.FEBRUARY, 23, 9, 11, 12); utcCal.set(Calendar.MILLISECOND, 0); text = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(utcCal); assertEquals("2002-02-23T09:11:12Z", text); @@ -141,7 +144,7 @@ public class DateFormatUtilsTest { public void testDateISO(){ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3"); final Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23,10,11,12); + cal.set(2002, Calendar.FEBRUARY, 23, 10, 11, 12); String text = DateFormatUtils.format(cal.getTime(), DateFormatUtils.ISO_DATE_FORMAT.getPattern(), timeZone); assertEquals("2002-02-23", text); @@ -165,7 +168,7 @@ public class DateFormatUtilsTest { public void testTimeISO(){ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3"); final Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23,10,11,12); + cal.set(2002, Calendar.FEBRUARY, 23, 10, 11, 12); String text = DateFormatUtils.format(cal.getTime(), DateFormatUtils.ISO_TIME_FORMAT.getPattern(), timeZone); assertEquals("T10:11:12", text); @@ -189,7 +192,7 @@ public class DateFormatUtilsTest { public void testTimeNoTISO(){ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3"); final Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23,10,11,12); + cal.set(2002, Calendar.FEBRUARY, 23, 10, 11, 12); String text = DateFormatUtils.format(cal.getTime(), DateFormatUtils.ISO_TIME_NO_T_FORMAT.getPattern(), timeZone); assertEquals("10:11:12", text); @@ -213,7 +216,7 @@ public class DateFormatUtilsTest { public void testSMTP(){ final TimeZone timeZone = TimeZone.getTimeZone("GMT-3"); final Calendar cal = Calendar.getInstance(timeZone); - cal.set(2003,5,8,10,11,12); + cal.set(2003, Calendar.JUNE, 8, 10, 11, 12); String text = DateFormatUtils.format(cal.getTime(), DateFormatUtils.SMTP_DATETIME_FORMAT.getPattern(), timeZone, DateFormatUtils.SMTP_DATETIME_FORMAT.getLocale()); diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java index fdca21a36..0f93c7727 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java @@ -211,13 +211,13 @@ public class DateUtilsTest { public void testIsSameInstant_Cal() { final GregorianCalendar cala = new GregorianCalendar(TimeZone.getTimeZone("GMT+1")); final GregorianCalendar calb = new GregorianCalendar(TimeZone.getTimeZone("GMT-1")); - cala.set(2004, 6, 9, 13, 45, 0); + cala.set(2004, Calendar.JULY, 9, 13, 45, 0); cala.set(Calendar.MILLISECOND, 0); - calb.set(2004, 6, 9, 13, 45, 0); + calb.set(2004, Calendar.JULY, 9, 13, 45, 0); calb.set(Calendar.MILLISECOND, 0); assertFalse(DateUtils.isSameInstant(cala, calb)); - calb.set(2004, 6, 9, 11, 45, 0); + calb.set(2004, Calendar.JULY, 9, 11, 45, 0); assertTrue(DateUtils.isSameInstant(cala, calb)); } @@ -231,21 +231,21 @@ public class DateUtilsTest { public void testIsSameLocalTime_Cal() { final GregorianCalendar cala = new GregorianCalendar(TimeZone.getTimeZone("GMT+1")); final GregorianCalendar calb = new GregorianCalendar(TimeZone.getTimeZone("GMT-1")); - cala.set(2004, 6, 9, 13, 45, 0); + cala.set(2004, Calendar.JULY, 9, 13, 45, 0); cala.set(Calendar.MILLISECOND, 0); - calb.set(2004, 6, 9, 13, 45, 0); + calb.set(2004, Calendar.JULY, 9, 13, 45, 0); calb.set(Calendar.MILLISECOND, 0); assertTrue(DateUtils.isSameLocalTime(cala, calb)); final Calendar calc = Calendar.getInstance(); final Calendar cald = Calendar.getInstance(); - calc.set(2004, 6, 9, 4, 0, 0); - cald.set(2004, 6, 9, 16, 0, 0); + calc.set(2004, Calendar.JULY, 9, 4, 0, 0); + cald.set(2004, Calendar.JULY, 9, 16, 0, 0); calc.set(Calendar.MILLISECOND, 0); cald.set(Calendar.MILLISECOND, 0); assertFalse("LANG-677", DateUtils.isSameLocalTime(calc, cald)); - calb.set(2004, 6, 9, 11, 45, 0); + calb.set(2004, Calendar.JULY, 9, 11, 45, 0); assertFalse(DateUtils.isSameLocalTime(cala, calb)); } @@ -871,19 +871,19 @@ public class DateUtilsTest { TimeZone.setDefault(defaultZone); dateTimeParser.setTimeZone(defaultZone); final Calendar testCalendar = Calendar.getInstance(); - testCalendar.set(2007, 6, 2, 8, 8, 50); + testCalendar.set(2007, Calendar.JULY, 2, 8, 8, 50); Date date = testCalendar.getTime(); assertEquals("Minute Round Up Failed", dateTimeParser.parse("July 2, 2007 08:09:00.000"), DateUtils.round(date, Calendar.MINUTE)); - testCalendar.set(2007, 6, 2, 8, 8, 20); + testCalendar.set(2007, Calendar.JULY, 2, 8, 8, 20); date = testCalendar.getTime(); assertEquals("Minute No Round Failed", dateTimeParser.parse("July 2, 2007 08:08:00.000"), DateUtils.round(date, Calendar.MINUTE)); - testCalendar.set(2007, 6, 2, 8, 8, 50); + testCalendar.set(2007, Calendar.JULY, 2, 8, 8, 50); testCalendar.set(Calendar.MILLISECOND, 600); date = testCalendar.getTime(); @@ -891,34 +891,34 @@ public class DateUtilsTest { dateTimeParser.parse("July 2, 2007 08:08:51.000"), DateUtils.round(date, Calendar.SECOND)); - testCalendar.set(2007, 6, 2, 8, 8, 50); + testCalendar.set(2007, Calendar.JULY, 2, 8, 8, 50); testCalendar.set(Calendar.MILLISECOND, 200); date = testCalendar.getTime(); assertEquals("Second Round Down with 200 Milli Seconds Failed", dateTimeParser.parse("July 2, 2007 08:08:50.000"), DateUtils.round(date, Calendar.SECOND)); - testCalendar.set(2007, 6, 2, 8, 8, 20); + testCalendar.set(2007, Calendar.JULY, 2, 8, 8, 20); testCalendar.set(Calendar.MILLISECOND, 600); date = testCalendar.getTime(); assertEquals("Second Round Up with 200 Milli Seconds Failed", dateTimeParser.parse("July 2, 2007 08:08:21.000"), DateUtils.round(date, Calendar.SECOND)); - testCalendar.set(2007, 6, 2, 8, 8, 20); + testCalendar.set(2007, Calendar.JULY, 2, 8, 8, 20); testCalendar.set(Calendar.MILLISECOND, 200); date = testCalendar.getTime(); assertEquals("Second Round Down with 200 Milli Seconds Failed", dateTimeParser.parse("July 2, 2007 08:08:20.000"), DateUtils.round(date, Calendar.SECOND)); - testCalendar.set(2007, 6, 2, 8, 8, 50); + testCalendar.set(2007, Calendar.JULY, 2, 8, 8, 50); date = testCalendar.getTime(); assertEquals("Hour Round Down Failed", dateTimeParser.parse("July 2, 2007 08:00:00.000"), DateUtils.round(date, Calendar.HOUR)); - testCalendar.set(2007, 6, 2, 8, 31, 50); + testCalendar.set(2007, Calendar.JULY, 2, 8, 31, 50); date = testCalendar.getTime(); assertEquals("Hour Round Up Failed", dateTimeParser.parse("July 2, 2007 09:00:00.000"), diff --git a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java index 1e83e41b0..15456428a 100644 --- a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java @@ -236,11 +236,11 @@ public class DurationFormatUtilsTest { assertEquals("01:00", DurationFormatUtils.formatDuration(duration, "mm:ss")); final Calendar base = Calendar.getInstance(); - base.set(2000, 0, 1, 0, 0, 0); + base.set(2000, Calendar.JANUARY, 1, 0, 0, 0); base.set(Calendar.MILLISECOND, 0); final Calendar cal = Calendar.getInstance(); - cal.set(2003, 1, 1, 0, 0, 0); + cal.set(2003, Calendar.FEBRUARY, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); duration = cal.getTime().getTime() - base.getTime().getTime(); // duration from 2000-01-01 to cal // don't use 1970 in test as time zones were less reliable in 1970 than now @@ -258,11 +258,11 @@ public class DurationFormatUtilsTest { public void testFormatPeriodISO() { final TimeZone timeZone = TimeZone.getTimeZone("GMT-3"); final Calendar base = Calendar.getInstance(timeZone); - base.set(1970, 0, 1, 0, 0, 0); + base.set(1970, Calendar.JANUARY, 1, 0, 0, 0); base.set(Calendar.MILLISECOND, 0); final Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002, 1, 23, 9, 11, 12); + cal.set(2002, Calendar.FEBRUARY, 23, 9, 11, 12); cal.set(Calendar.MILLISECOND, 1); String text; // repeat a test from testDateTimeISO to compare extended and not extended. @@ -273,7 +273,7 @@ public class DurationFormatUtilsTest { DurationFormatUtils.ISO_EXTENDED_FORMAT_PATTERN, false, timeZone); assertEquals("P32Y1M22DT9H11M12.001S", text); // test fixture from example in http://www.w3.org/TR/xmlschema-2/#duration - cal.set(1971, 1, 3, 10, 30, 0); + cal.set(1971, Calendar.FEBRUARY, 3, 10, 30, 0); cal.set(Calendar.MILLISECOND, 0); text = DurationFormatUtils.formatPeriod(base.getTime().getTime(), cal.getTime().getTime(), DurationFormatUtils.ISO_EXTENDED_FORMAT_PATTERN, false, timeZone); @@ -297,7 +297,7 @@ public class DurationFormatUtilsTest { @Test public void testFormatPeriod() { final Calendar cal1970 = Calendar.getInstance(); - cal1970.set(1970, 0, 1, 0, 0, 0); + cal1970.set(1970, Calendar.JANUARY, 1, 0, 0, 0); cal1970.set(Calendar.MILLISECOND, 0); final long time1970 = cal1970.getTime().getTime(); @@ -323,21 +323,21 @@ public class DurationFormatUtilsTest { assertEquals("01:00", DurationFormatUtils.formatPeriod(time1970, time, "mm:ss")); final Calendar cal = Calendar.getInstance(); - cal.set(1973, 6, 1, 0, 0, 0); + cal.set(1973, Calendar.JULY, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); time = cal.getTime().getTime(); assertEquals("36", DurationFormatUtils.formatPeriod(time1970, time, "yM")); assertEquals("3 years 6 months", DurationFormatUtils.formatPeriod(time1970, time, "y' years 'M' months'")); assertEquals("03/06", DurationFormatUtils.formatPeriod(time1970, time, "yy/MM")); - cal.set(1973, 10, 1, 0, 0, 0); + cal.set(1973, Calendar.NOVEMBER, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); time = cal.getTime().getTime(); assertEquals("310", DurationFormatUtils.formatPeriod(time1970, time, "yM")); assertEquals("3 years 10 months", DurationFormatUtils.formatPeriod(time1970, time, "y' years 'M' months'")); assertEquals("03/10", DurationFormatUtils.formatPeriod(time1970, time, "yy/MM")); - cal.set(1974, 0, 1, 0, 0, 0); + cal.set(1974, Calendar.JANUARY, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); time = cal.getTime().getTime(); assertEquals("40", DurationFormatUtils.formatPeriod(time1970, time, "yM")); @@ -423,10 +423,10 @@ public class DurationFormatUtilsTest { @Test public void testLANG815() { final Calendar calendar = Calendar.getInstance(); - calendar.set(2012, 6, 30, 0, 0, 0); + calendar.set(2012, Calendar.JULY, 30, 0, 0, 0); final long startMillis = calendar.getTimeInMillis(); - calendar.set(2012, 8, 8); + calendar.set(2012, Calendar.SEPTEMBER, 8); final long endMillis = calendar.getTimeInMillis(); assertEquals("1 9", DurationFormatUtils.formatPeriod(startMillis, endMillis, "M d")); 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 c4e0f95ae..3651eae0b 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -117,7 +117,7 @@ public class FastDateParserTest { public void testParseZone() throws ParseException { final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US); cal.clear(); - cal.set(2003, 6, 10, 16, 33, 20); + cal.set(2003, Calendar.JULY, 10, 16, 33, 20); final DateParser fdf = getInstance(yMdHmsSZ, NEW_YORK, Locale.US); @@ -127,12 +127,12 @@ public class FastDateParserTest { assertEquals(cal.getTime(), fdf.parse("2003-07-10T16:33:20.000 EDT")); cal.setTimeZone(TimeZone.getTimeZone("GMT-3")); - cal.set(2003, 1, 10, 9, 0, 0); + cal.set(2003, Calendar.FEBRUARY, 10, 9, 0, 0); assertEquals(cal.getTime(), fdf.parse("2003-02-10T09:00:00.000 -0300")); cal.setTimeZone(TimeZone.getTimeZone("GMT+5")); - cal.set(2003, 1, 10, 15, 5, 6); + cal.set(2003, Calendar.FEBRUARY, 10, 15, 5, 6); assertEquals(cal.getTime(), fdf.parse("2003-02-10T15:05:06.000 +0500")); } @@ -141,7 +141,7 @@ public class FastDateParserTest { public void testParseLongShort() throws ParseException { final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US); cal.clear(); - cal.set(2003, 1, 10, 15, 33, 20); + cal.set(2003, Calendar.FEBRUARY, 10, 15, 33, 20); cal.set(Calendar.MILLISECOND, 989); cal.setTimeZone(NEW_YORK); @@ -170,25 +170,25 @@ public class FastDateParserTest { final DateParser k = getInstance("yyyy-MM-dd kk:mm:ss", NEW_YORK, Locale.US); final DateParser H = getInstance("yyyy-MM-dd HH:mm:ss", NEW_YORK, Locale.US); - cal.set(2010, 7, 1, 0, 33, 20); + cal.set(2010, Calendar.AUGUST, 1, 0, 33, 20); assertEquals(cal.getTime(), h.parse("2010-08-01 12 AM 33:20")); assertEquals(cal.getTime(), K.parse("2010-08-01 0 AM 33:20")); assertEquals(cal.getTime(), k.parse("2010-08-01 00:33:20")); assertEquals(cal.getTime(), H.parse("2010-08-01 00:33:20")); - cal.set(2010, 7, 1, 3, 33, 20); + cal.set(2010, Calendar.AUGUST, 1, 3, 33, 20); assertEquals(cal.getTime(), h.parse("2010-08-01 3 AM 33:20")); assertEquals(cal.getTime(), K.parse("2010-08-01 3 AM 33:20")); assertEquals(cal.getTime(), k.parse("2010-08-01 03:33:20")); assertEquals(cal.getTime(), H.parse("2010-08-01 03:33:20")); - cal.set(2010, 7, 1, 15, 33, 20); + cal.set(2010, Calendar.AUGUST, 1, 15, 33, 20); assertEquals(cal.getTime(), h.parse("2010-08-01 3 PM 33:20")); assertEquals(cal.getTime(), K.parse("2010-08-01 3 PM 33:20")); assertEquals(cal.getTime(), k.parse("2010-08-01 15:33:20")); assertEquals(cal.getTime(), H.parse("2010-08-01 15:33:20")); - cal.set(2010, 7, 1, 12, 33, 20); + cal.set(2010, Calendar.AUGUST, 1, 12, 33, 20); assertEquals(cal.getTime(), h.parse("2010-08-01 12 PM 33:20")); assertEquals(cal.getTime(), K.parse("2010-08-01 0 PM 33:20")); assertEquals(cal.getTime(), k.parse("2010-08-01 12:33:20")); @@ -322,7 +322,7 @@ public class FastDateParserTest { final Calendar cal= Calendar.getInstance(GMT); cal.clear(); - cal.set(2003, 1, 10); + cal.set(2003, Calendar.FEBRUARY, 10); if (eraBC) { cal.set(Calendar.ERA, GregorianCalendar.BC); } @@ -370,7 +370,7 @@ public class FastDateParserTest { public void testParseNumerics() throws ParseException { final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US); cal.clear(); - cal.set(2003, 1, 10, 15, 33, 20); + cal.set(2003, Calendar.FEBRUARY, 10, 15, 33, 20); cal.set(Calendar.MILLISECOND, 989); final DateParser fdf = getInstance("yyyyMMddHHmmssSSS", NEW_YORK, Locale.US); @@ -381,7 +381,7 @@ public class FastDateParserTest { public void testQuotes() throws ParseException { final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US); cal.clear(); - cal.set(2003, 1, 10, 15, 33, 20); + cal.set(2003, Calendar.FEBRUARY, 10, 15, 33, 20); cal.set(Calendar.MILLISECOND, 989); final DateParser fdf = getInstance("''yyyyMMdd'A''B'HHmmssSSS''", NEW_YORK, Locale.US); @@ -459,7 +459,7 @@ public class FastDateParserTest { public void testDayOf() throws ParseException { final Calendar cal= Calendar.getInstance(NEW_YORK, Locale.US); cal.clear(); - cal.set(2003, 1, 10); + cal.set(2003, Calendar.FEBRUARY, 10); final DateParser fdf = getInstance("W w F D y", NEW_YORK, Locale.US); assertEquals(cal.getTime(), fdf.parse("3 7 2 41 03")); @@ -475,7 +475,7 @@ public class FastDateParserTest { final Calendar cal = Calendar.getInstance(); cal.clear(); - cal.set(2004, 1, 3); + cal.set(2004, Calendar.FEBRUARY, 3); assertEquals(cal.getTime(), fdf.parse("2/3/04")); fdf = getDateInstance(FastDateFormat.SHORT, SWEDEN); @@ -492,13 +492,13 @@ public class FastDateParserTest { final Calendar cal = Calendar.getInstance(); cal.clear(); - cal.set(1,0,1); + cal.set(1, Calendar.JANUARY, 1); assertEquals(cal.getTime(), parser.parse("0001/01/01")); - cal.set(10,0,1); + cal.set(10, Calendar.JANUARY, 1); assertEquals(cal.getTime(), parser.parse("0010/01/01")); - cal.set(100,0,1); + cal.set(100, Calendar.JANUARY, 1); assertEquals(cal.getTime(), parser.parse("0100/01/01")); - cal.set(999,0,1); + cal.set(999, Calendar.JANUARY, 1); assertEquals(cal.getTime(), parser.parse("0999/01/01")); } @@ -508,7 +508,7 @@ public class FastDateParserTest { final Calendar cal = Calendar.getInstance(); cal.clear(); - cal.set(1000,0,1); + cal.set(1000, Calendar.JANUARY, 1); assertEquals(cal.getTime(), parser.parse("01.01.1000")); } @@ -516,7 +516,7 @@ public class FastDateParserTest { public void testLang303() throws ParseException { DateParser parser = getInstance(YMD_SLASH); final Calendar cal = Calendar.getInstance(); - cal.set(2004, 11, 31); + cal.set(2004, Calendar.DECEMBER, 31); final Date date = parser.parse("2004/11/31"); @@ -530,7 +530,7 @@ public class FastDateParserTest { final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-8")); cal.clear(); - cal.set(2009, 9, 16, 8, 42, 16); + cal.set(2009, Calendar.OCTOBER, 16, 8, 42, 16); assertEquals(cal.getTime(), parser.parse("2009-10-16T16:42:16.000Z")); } @@ -574,7 +574,7 @@ public class FastDateParserTest { public void testLang996() throws ParseException { final Calendar expected = Calendar.getInstance(NEW_YORK, Locale.US); expected.clear(); - expected.set(2014, 4, 14); + expected.set(2014, Calendar.MAY, 14); final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US); assertEquals(expected.getTime(), fdp.parse("14may2014")); 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 d72d7fb5d..f8b4930dc 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java @@ -16,7 +16,9 @@ */ package org.apache.commons.lang3.time; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.Serializable; import java.text.ParseException; @@ -80,7 +82,7 @@ public class FastDatePrinterTest { TimeZone.setDefault(NEW_YORK); final GregorianCalendar cal1 = new GregorianCalendar(2003, 0, 10, 15, 33, 20); - final GregorianCalendar cal2 = new GregorianCalendar(2003, 6, 10, 9, 00, 00); + final GregorianCalendar cal2 = new GregorianCalendar(2003, 6, 10, 9, 0, 0); final Date date1 = cal1.getTime(); final Date date2 = cal2.getTime(); final long millis1 = date1.getTime(); @@ -135,7 +137,7 @@ public class FastDatePrinterTest { final Locale usLocale = Locale.US; final Locale swedishLocale = new Locale("sv", "SE"); final Calendar cal = Calendar.getInstance(); - cal.set(2004, 1, 3); + cal.set(2004, Calendar.FEBRUARY, 3); DatePrinter fdf = getDateInstance(FastDateFormat.SHORT, usLocale); assertEquals("2/3/04", fdf.format(cal)); @@ -152,13 +154,13 @@ public class FastDatePrinterTest { final Calendar cal = Calendar.getInstance(); final DatePrinter format = getInstance(YYYY_MM_DD); - cal.set(1,0,1); + cal.set(1, Calendar.JANUARY, 1); assertEquals("0001/01/01", format.format(cal)); - cal.set(10,0,1); + cal.set(10, Calendar.JANUARY, 1); assertEquals("0010/01/01", format.format(cal)); - cal.set(100,0,1); + cal.set(100, Calendar.JANUARY, 1); assertEquals("0100/01/01", format.format(cal)); - cal.set(999,0,1); + cal.set(999, Calendar.JANUARY, 1); assertEquals("0999/01/01", format.format(cal)); } /** @@ -169,7 +171,7 @@ public class FastDatePrinterTest { final Calendar cal = Calendar.getInstance(); final DatePrinter format = getInstance("dd.MM.yyyy"); - cal.set(1000,0,1); + cal.set(1000, Calendar.JANUARY, 1); assertEquals("01.01.1000", format.format(cal)); } @@ -182,18 +184,18 @@ public class FastDatePrinterTest { final Calendar cal = Calendar.getInstance(); final DatePrinter format = getInstance(YYYY_MM_DD); - cal.set(2004,11,31); + cal.set(2004, Calendar.DECEMBER, 31); assertEquals("2004/12/31", format.format(cal)); - cal.set(999,11,31); + cal.set(999, Calendar.DECEMBER, 31); assertEquals("0999/12/31", format.format(cal)); - cal.set(1,2,2); + cal.set(1, Calendar.MARCH, 2); assertEquals("0001/03/02", format.format(cal)); } @Test public void testLang303() { final Calendar cal = Calendar.getInstance(); - cal.set(2004, 11, 31); + cal.set(2004, Calendar.DECEMBER, 31); DatePrinter format = getInstance(YYYY_MM_DD); final String output = format.format(cal); @@ -208,7 +210,7 @@ public class FastDatePrinterTest { // for the unit test to work in any time zone, constructing with GMT-8 rather than default locale time zone final GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT-8")); cal.clear(); - cal.set(2009, 9, 16, 8, 42, 16); + cal.set(2009, Calendar.OCTOBER, 16, 8, 42, 16); final DatePrinter format = getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("GMT")); assertEquals("dateTime", "2009-10-16T16:42:16.000Z", format.format(cal.getTime())); @@ -220,7 +222,7 @@ public class FastDatePrinterTest { final Locale locale = new Locale("sv", "SE"); final Calendar cal = Calendar.getInstance(); - cal.set(2010, 0, 1, 12, 0, 0); + cal.set(2010, Calendar.JANUARY, 1, 12, 0, 0); final Date d = cal.getTime(); final DatePrinter fdf = getInstance("EEEE', week 'ww", locale);