Package com.google.ical.util

Examples of com.google.ical.util.DTBuilder.toDate()


  public String goldenDateRange(String dateStr, int interval) throws Exception {
    PeriodValue period = IcalParseUtil.parsePeriodValue(dateStr);
    DTBuilder b = new DTBuilder(period.start());
    StringBuilder out = new StringBuilder();
    while (true) {
      DateValue d = b.toDate();
      if (d.compareTo(period.end()) > 0) { break; }
      if (0 != out.length()) { out.append(','); }
      out.append(d);
      b.day += interval;
    }
View Full Code Here


  public void testRollToNextWeekStart() throws Exception {
    DTBuilder builder;

    builder = new DTBuilder(2006, 1, 23);
    Util.rollToNextWeekStart(builder, Weekday.TU);
    assertEquals("20060124", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 24);
    Util.rollToNextWeekStart(builder, Weekday.TU);
    assertEquals("20060124", builder.toDate().toString());
View Full Code Here

    Util.rollToNextWeekStart(builder, Weekday.TU);
    assertEquals("20060124", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 24);
    Util.rollToNextWeekStart(builder, Weekday.TU);
    assertEquals("20060124", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 25);
    Util.rollToNextWeekStart(builder, Weekday.TU);
    assertEquals("20060131", builder.toDate().toString());
View Full Code Here

    Util.rollToNextWeekStart(builder, Weekday.TU);
    assertEquals("20060124", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 25);
    Util.rollToNextWeekStart(builder, Weekday.TU);
    assertEquals("20060131", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 23);
    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060123", builder.toDate().toString());
View Full Code Here

    Util.rollToNextWeekStart(builder, Weekday.TU);
    assertEquals("20060131", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 23);
    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060123", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 24);
    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060130", builder.toDate().toString());
View Full Code Here

    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060123", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 24);
    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060130", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 25);
    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060130", builder.toDate().toString());
View Full Code Here

    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060130", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 25);
    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060130", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 31);
    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060206", builder.toDate().toString());
  }
View Full Code Here

    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060130", builder.toDate().toString());

    builder = new DTBuilder(2006, 1, 31);
    Util.rollToNextWeekStart(builder, Weekday.MO);
    assertEquals("20060206", builder.toDate().toString());
  }

  public void testNextWeekStart() throws Exception {
    assertEquals(new DateValueImpl(2006, 1, 24),
                 Util.nextWeekStart(new DateValueImpl(2006, 1, 23),
View Full Code Here

        {
          // step back one interval
          DTBuilder dtStartMinus1B = new DTBuilder(dtStart);
          dtStartMinus1B.day -= interval;
          DateValue dtStartMinus1 = dtStartMinus1B.toDate();
          year = dtStartMinus1.year();
          month = dtStartMinus1.month();
          date = dtStartMinus1.day();
          nDays = TimeUtils.monthLength(year, month);
        }
View Full Code Here

      {
        // the latest day with day of week wkst on or before dtStart
        DTBuilder wkStartB = new DTBuilder(dtStart);
        wkStartB.day -=
          (7 + Weekday.valueOf(dtStart).javaDayNum - wkst.javaDayNum) % 7;
        wkStart = wkStartB.toDate();
      }

      public boolean apply(DateValue date) {
        int daysBetween = TimeUtils.daysBetween(date, wkStart);
        if (daysBetween < 0) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.