You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by gg...@apache.org on 2005/08/12 06:36:44 UTC
svn commit: r232202 - in
/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time:
DateFormatUtilsTest.java DateUtilsTest.java
Author: ggregory
Date: Thu Aug 11 21:36:42 2005
New Revision: 232202
URL: http://svn.apache.org/viewcvs?rev=232202&view=rev
Log:
Patches to increase test coverage from Nathan Beyer [nbeyer@kc.rr.com]
Modified:
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateFormatUtilsTest.java
jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java
Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateFormatUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateFormatUtilsTest.java?rev=232202&r1=232201&r2=232202&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateFormatUtilsTest.java (original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateFormatUtilsTest.java Thu Aug 11 21:36:42 2005
@@ -18,6 +18,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.util.Calendar;
+import java.util.Locale;
import java.util.TimeZone;
import junit.framework.Test;
@@ -61,6 +62,40 @@
}
//-----------------------------------------------------------------------
+ public void testFormat() {
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ c.set(2005,0,1,12,0,0);
+ c.setTimeZone(TimeZone.getDefault());
+ StringBuffer buffer = new StringBuffer ();
+ int year = c.get(Calendar.YEAR);
+ int month = c.get(Calendar.MONTH) + 1;
+ int day = c.get(Calendar.DAY_OF_MONTH);
+ int hour = c.get(Calendar.HOUR_OF_DAY);
+ buffer.append (year);
+ buffer.append(month);
+ buffer.append(day);
+ buffer.append(hour);
+ assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH"));
+
+ assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime().getTime(), "yyyyMdH"));
+
+ assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH", Locale.US));
+
+ assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime().getTime(), "yyyyMdH", Locale.US));
+ }
+
+ public void testFormatUTC() {
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ c.set(2005,0,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()));
+
+ assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US));
+
+ assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US));
+ }
+
public void testDateTimeISO(){
TimeZone timeZone = TimeZone.getTimeZone("GMT-3");
Calendar cal = Calendar.getInstance(timeZone);
Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java?rev=232202&r1=232201&r2=232202&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java (original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/time/DateUtilsTest.java Thu Aug 11 21:36:42 2005
@@ -303,6 +303,8 @@
assertEquals("round semimonth-2 failed",
dateParser.parse("November 16, 2001"),
DateUtils.round(date2, DateUtils.SEMI_MONTH));
+
+
assertEquals("round date-1 failed",
dateParser.parse("February 13, 2002"),
DateUtils.round(date1, Calendar.DATE));
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org