You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2015/04/29 22:31:02 UTC
[3/6] [lang] Use Calendar constants in DateFormatUtilsTest
Use Calendar constants in DateFormatUtilsTest
Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/90e31fd9
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/90e31fd9
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/90e31fd9
Branch: refs/heads/master
Commit: 90e31fd93fdcaedadcd4b030fbc20f7375672def
Parents: ea60fbe
Author: Benedikt Ritter <br...@apache.org>
Authored: Wed Apr 29 22:23:55 2015 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Wed Apr 29 22:23:55 2015 +0200
----------------------------------------------------------------------
.../commons/lang3/time/DateFormatUtilsTest.java | 27 +++++++++++---------
1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-lang/blob/90e31fd9/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java
----------------------------------------------------------------------
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 3b0d11f..b0a6b5d 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());