Пример #1
0
 @Test
 public void now() throws Exception {
   assertTrue(sufficientlyEqual(DynamicDate.getInstance("now"), new Date()));
   assertTrue(
       sufficientlyEqual(
           DynamicDate.getInstance("now - 5 minute"),
           new Date(System.currentTimeMillis() - 5 * 60 * 1000)));
   assertTrue(
       sufficientlyEqual(
           DynamicDate.getInstance("now + 5 minute"),
           new Date(System.currentTimeMillis() + 5 * 60 * 1000)));
   assertTrue(
       sufficientlyEqual(
           DynamicDate.getInstance("now + 5 hour"),
           new Date(System.currentTimeMillis() + 5 * 60 * 60 * 1000)));
 }
Пример #2
0
 @Test
 public void today() {
   try {
     Calendar today = Calendar.getInstance();
     beginOfDay(today);
     assertTrue(sufficientlyEqual(DynamicDate.getInstance("today"), today.getTime()));
   } catch (Exception e) {
     fail(e.getMessage());
   }
 }
Пример #3
0
 protected void assertValue(String date1, int[] date2) throws ParseException {
   Date dyndate = DynamicDate.getInstance(date1);
   int[] r = getNow(date2);
   Collection result = compare(dyndate, r);
   assertTrue(
       date1
           + "->"
           + dyndate
           + " != "
           + new Date(r[0] - 1900, r[1], r[2], r[3], r[4], r[5])
           + result,
       result.isEmpty());
 }
Пример #4
0
 @Test
 public void day() throws ParseException {
   assertValue("today", new int[] {0, 0, 0, NULL, NULL, NULL});
   assertValue("today + 1 day", new int[] {0, 0, 1, NULL, NULL, NULL});
   assertValue("tomorrow", new int[] {0, 0, 1, NULL, NULL, NULL});
   // for now only checking if no exception:
   DynamicDate.getInstance("tomorrow 5 oclock");
   DynamicDate.getInstance("now 5 oclock");
   DynamicDate.getInstance("2006-01-10T06:12Z");
   DynamicDate.getInstance("2006-01-10 06:12");
   // DynamicDate.getInstance("2006-01-10 06:12 TZ CET");
   DynamicDate.getInstance("2006-01-10 5 oclock");
   DynamicDate.getInstance("friday");
   DynamicDate.getInstance("next friday");
   DynamicDate.getInstance("previous friday");
 }