Package com.mdimension.jchronic.utils

Examples of com.mdimension.jchronic.utils.Span


  }

  public void testNextPast() {
    RepeaterHour hours = new RepeaterHour();
    hours.setStart(_now);
    Span lastHour = hours.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 8, 16, 13), lastHour.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 14), lastHour.getEndCalendar());

    Span lastLastHour = hours.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 8, 16, 12), lastLastHour.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 13), lastLastHour.getEndCalendar());
  }
View Full Code Here


    _now = Time.construct(2006, 8, 16, 14, 30);

    RepeaterHour hours = new RepeaterHour();
    hours.setStart(_now);

    Span thisHour;
    thisHour = hours.thisSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 16, 14, 31), thisHour.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 15), thisHour.getEndCalendar());

    thisHour = hours.thisSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 8, 16, 14), thisHour.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 14, 30), thisHour.getEndCalendar());
  }
View Full Code Here

    assertEquals(Time.construct(2006, 8, 16, 14), thisHour.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16, 14, 30), thisHour.getEndCalendar());
  }

  public void testOffset() {
      Span span = new Span(_now, Calendar.SECOND, 1);

      Span offsetSpan;
      offsetSpan = new RepeaterHour().getOffset(span, 3, Pointer.PointerType.FUTURE);

      assertEquals(Time.construct(2006, 8, 16, 17), offsetSpan.getBeginCalendar());
      assertEquals(Time.construct(2006, 8, 16, 17, 0, 1), offsetSpan.getEndCalendar());

      offsetSpan = new RepeaterHour().getOffset(span, 24, Pointer.PointerType.PAST);

      assertEquals(Time.construct(2006, 8, 15, 14), offsetSpan.getBeginCalendar());
      assertEquals(Time.construct(2006, 8, 15, 14, 0, 1), offsetSpan.getEndCalendar());
  }
View Full Code Here

  public void testNextFuture() {
    RepeaterYear years = new RepeaterYear();
    years.setStart(_now);

    Span nextYear = years.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2007, 1, 1), nextYear.getBeginCalendar());
    assertEquals(Time.construct(2008, 1, 1), nextYear.getEndCalendar());

    Span nextNextYear = years.nextSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2008, 1, 1), nextNextYear.getBeginCalendar());
    assertEquals(Time.construct(2009, 1, 1), nextNextYear.getEndCalendar());
  }
View Full Code Here

  }

  public void testNextPast() {
    RepeaterYear years = new RepeaterYear();
    years.setStart(_now);
    Span lastYear = years.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2005, 1, 1), lastYear.getBeginCalendar());
    assertEquals(Time.construct(2006, 1, 1), lastYear.getEndCalendar());

    Span lastLastYear = years.nextSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2004, 1, 1), lastLastYear.getBeginCalendar());
    assertEquals(Time.construct(2005, 1, 1), lastLastYear.getEndCalendar());
  }
View Full Code Here

  public void testThis() {
    RepeaterYear years = new RepeaterYear();
    years.setStart(_now);

    Span thisYear;
    thisYear = years.thisSpan(Pointer.PointerType.FUTURE);
    assertEquals(Time.construct(2006, 8, 17), thisYear.getBeginCalendar());
    assertEquals(Time.construct(2007, 1, 1), thisYear.getEndCalendar());

    thisYear = years.thisSpan(Pointer.PointerType.PAST);
    assertEquals(Time.construct(2006, 1, 1), thisYear.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16), thisYear.getEndCalendar());
  }
View Full Code Here

    assertEquals(Time.construct(2006, 1, 1), thisYear.getBeginCalendar());
    assertEquals(Time.construct(2006, 8, 16), thisYear.getEndCalendar());
  }

  public void testOffset() {
      Span span = new Span(_now, Calendar.SECOND, 1);

      Span offsetSpan;
      offsetSpan = new RepeaterYear().getOffset(span, 3, Pointer.PointerType.FUTURE);

      assertEquals(Time.construct(2009, 8, 16, 14), offsetSpan.getBeginCalendar());
      assertEquals(Time.construct(2009, 8, 16, 14, 0, 1), offsetSpan.getEndCalendar());

      offsetSpan = new RepeaterYear().getOffset(span, 10, Pointer.PointerType.PAST);

      assertEquals(Time.construct(1996, 8, 16, 14), offsetSpan.getBeginCalendar());
      assertEquals(Time.construct(1996, 8, 16, 14, 0, 1), offsetSpan.getEndCalendar());
  }
View Full Code Here

   
   
    @SuppressWarnings("unchecked")
    @Override
    public <T> T generateValue() {
        Span span = Chronic.parse(dateText, options);
        return (T) (span != null ? span.getBeginCalendar() : null);
    }
View Full Code Here

TOP

Related Classes of com.mdimension.jchronic.utils.Span

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.