abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1221627 - in /abdera/abdera2: common/src/main/java/org/apache/abdera2/common/date/DateTimes.java test/src/main/java/org/apache/abdera2/test/common/date/DateTimesTest.java
Date Wed, 21 Dec 2011 06:37:26 GMT
Author: jmsnell
Date: Wed Dec 21 06:37:26 2011
New Revision: 1221627

URL: http://svn.apache.org/viewvc?rev=1221627&view=rev
Log:
Bug fixes and test cases

Added:
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/date/DateTimesTest.java
  (with props)
Modified:
    abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java

Modified: abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java?rev=1221627&r1=1221626&r2=1221627&view=diff
==============================================================================
--- abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java (original)
+++ abdera/abdera2/common/src/main/java/org/apache/abdera2/common/date/DateTimes.java Wed
Dec 21 06:37:26 2011
@@ -321,10 +321,18 @@ public final class DateTimes {
     }
   }
 
+  public static DateTime utc(String dt) {
+    return dt(dt, DateTimeZone.UTC);
+  }
+  
   public static DateTime dt(String dt) {
     return new DateTime(dt);
   }
   
+  public static DateTime dt(String dt, DateTimeZone dtz) {
+    return new DateTime(dt,dtz);
+  }
+  
   public static DateTime dt(Date date) {
     return new DateTime(date);
   }

Added: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/date/DateTimesTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/date/DateTimesTest.java?rev=1221627&view=auto
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/date/DateTimesTest.java
(added)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/date/DateTimesTest.java
Wed Dec 21 06:37:26 2011
@@ -0,0 +1,50 @@
+package org.apache.abdera2.test.common.date;
+
+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 static org.apache.abdera2.common.date.DateTimes.*;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.junit.Test;
+
+public class DateTimesTest {
+
+  @Test
+  public void testDateTimes() {
+    
+    DateTime dt = now();
+    assertNotNull(dt);
+    
+    dt = utc("2012-12-12T12:12:12-00:00");
+    assertEquals(2012,dt.getYear());
+    assertEquals(12,dt.getMonthOfYear());
+    assertEquals(12,dt.getDayOfMonth());
+    assertEquals(12,dt.getHourOfDay());
+    assertEquals(12,dt.getMinuteOfHour());
+    assertEquals(12,dt.getSecondOfMinute());
+    assertEquals(DateTimeZone.UTC, dt.getZone());
+    
+    assertEquals("2012-12-12T12:12:12.000Z", format(dt));
+    
+    // not testing every combination here.. just making sure basic mechanism works...
+    
+    assertTrue(after(dt("2012-12-12T12:12:11-00:00")).apply(dt));
+    assertFalse(afterBetweenOrAt(dt("2012-12-12T12:12:12-00:00"),dt("2012-12-12T12:12:14-00:00")).apply(dt));
+    assertTrue(afterBetweenOrAt(dt("2012-12-12T12:12:11-00:00"),dt("2012-12-12T12:12:13-00:00")).apply(dt));
+    assertTrue(afterBetweenOrAt(dt("2012-12-12T12:12:10-00:00"),dt("2012-12-12T12:12:12-00:00")).apply(dt));
+    
+    assertTrue(afterNow().apply(now().plusMinutes(1)));
+    assertFalse(afterNow().apply(now().minusMinutes(1)));
+    
+    assertTrue(atBetweenOrBefore(dt("2012-12-12T12:12:12-00:00"),dt("2012-12-12T12:12:14-00:00")).apply(dt));
+    assertTrue(atBetweenOrBefore(dt("2012-12-12T12:12:11-00:00"),dt("2012-12-12T12:12:13-00:00")).apply(dt));
+    assertFalse(atBetweenOrBefore(dt("2012-12-12T12:12:10-00:00"),dt("2012-12-12T12:12:12-00:00")).apply(dt));
+    
+    assertTrue(equivalent(dt, "2012-12-12T12:12:12-00:00"));
+    assertTrue(equivalent(toTimeZone(dt,"EST"),"2012-12-12T12:12:12-00:00"));
+  }
+  
+}

Propchange: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/date/DateTimesTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message