Package com.google.ical.values

Examples of com.google.ical.values.DateValueImpl


    c.setTime(date);
    int h = c.get(Calendar.HOUR_OF_DAY),
      m = c.get(Calendar.MINUTE),
      s = c.get(Calendar.SECOND);
    if (midnightAsDate && 0 == (h | m | s)) {
      return new DateValueImpl(c.get(Calendar.YEAR),
                               c.get(Calendar.MONTH) + 1,
                               c.get(Calendar.DAY_OF_MONTH));
    } else {
      return new DateTimeValueImpl(c.get(Calendar.YEAR),
                                   c.get(Calendar.MONTH) + 1,
View Full Code Here


            2, IcalParseUtil.parseDateValue("20060101")),
        new DTBuilder(2006, 1, 1), "year", "2006, 2008, 2010, 2012, 2014", 5);
  }

  public void testSerialHourGeneratorGivenDate() throws Exception {
    DateValue dtStart = new DateValueImpl(2011, 8, 8);
    Generator g = Generators.serialHourGenerator(7, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 0:0:0", b.toString());
    assertTrue(g.generate(b));
View Full Code Here

    assertTrue(g.generate(b));
    assertEquals("2011-8-4 6:29:50", b.toString());
  }

  public void testByHourGeneratorGivenDate() throws Exception {
    DateValue dtStart = new DateValueImpl(2011, 8, 8);
    Generator g = Generators.byHourGenerator(new int[] { 3, 9, 11 }, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 3:0:0", b.toString());
    assertTrue(g.generate(b));
View Full Code Here

    assertTrue(g.generate(b));
    assertEquals("2011-8-11 6:50:0", b.toString());
  }

  public void testSerialMinuteGeneratorSmallInterval() throws Exception {
    DateValue dtStart = new DateValueImpl(2011, 8, 8);
    Generator g = Generators.serialMinuteGenerator(15, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 0:0:0", b.toString());
    assertTrue(g.generate(b));
View Full Code Here

  static LocalDate dateValueToLocalDate(DateValue dvUtc) {
    return new LocalDate(dvUtc.year(), dvUtc.month(), dvUtc.day());
  }

  static DateValue localDateToDateValue(LocalDate date) {
    return new DateValueImpl(
        date.getYear(), date.getMonthOfYear(), date.getDayOfMonth());
  }
View Full Code Here

      TimeZone.getTimeZone("America/Los_Angeles");

  public void testDateValueToDate() throws Exception {
    assertEquals(createDateUtc(2006, 10, 13, 0, 0, 0),
                 DateIteratorFactory.dateValueToDate(
                     new DateValueImpl(2006, 10, 13)));
    assertEquals(createDateUtc(2006, 10, 13, 12, 30, 1),
                 DateIteratorFactory.dateValueToDate(
                     new DateTimeValueImpl(2006, 10, 13, 12, 30, 1)));
  }
View Full Code Here

  public void testDateToDateTimeValue() throws Exception {
    assertEquals(new DateTimeValueImpl(2006, 10, 13, 0, 0, 0),
                 DateIteratorFactory.dateToDateValue(
                     createDateUtc(2006, 10, 13, 0, 0, 0), false));
    assertEquals(new DateValueImpl(2006, 10, 13),
                 DateIteratorFactory.dateToDateValue(
                     createDateUtc(2006, 10, 13, 0, 0, 0), true));
    assertEquals(new DateTimeValueImpl(2006, 10, 13, 12, 30, 1),
                 DateIteratorFactory.dateToDateValue(
                     createDateUtc(2006, 10, 13, 12, 30, 1), false));
View Full Code Here

                 DateIteratorFactory.dateToDateValue(
                     createDateUtc(2006, 10, 13, 12, 30, 1), true));
  }

  public void testConsistency() throws Exception {
    DateValue dv = new DateValueImpl(2006, 10, 13),
             dtv = new DateTimeValueImpl(2006, 10, 13, 12, 30, 1);
    assertEquals(dv, DateIteratorFactory.dateToDateValue(
                          DateIteratorFactory.dateValueToDate(dv), true));
    assertEquals(dtv, DateIteratorFactory.dateToDateValue(
                          DateIteratorFactory.dateValueToDate(dtv), true));
View Full Code Here

    c.set(ye, mo - 1, da, ho, mi, se);
    return c.getTime();
  }

  private static Date date(int y, int m, int d) {
    return DateIteratorFactory.dateValueToDate(new DateValueImpl(y, m, d));
  }
View Full Code Here

      }
    }
  }

  public void testDurationConstructor() throws Exception {
    final DateValue DV = new DateValueImpl(2005, 2, 15);
    final DateTimeValue DTV0 = new DateTimeValueImpl(2005, 2, 15, 0, 0, 0),
      DTV12 = new DateTimeValueImpl(2005, 2, 15, 12, 0, 0);
    DateValue ONE_DAY = new DateValueImpl(0, 0, 1),
      YESTERDAY = new DateValueImpl(0, 0, -1),
      ONE_WEEK = new DateValueImpl(0, 0, 7),
      ONE_MONTH = new DateValueImpl(0, 1, 0),
      ONE_YEAR = new DateValueImpl(1, 0, 0);
    DateTimeValue ONE_HOUR = new DateTimeValueImpl(0, 0, 0, 1, 0, 0),
      TWELVE_HOURS = new DateTimeValueImpl(0, 0, 0, 12, 0, 0),
      SAME_TIME = new DateTimeValueImpl(0, 0, 0, 0, 0, 0);

    assertEquals(PeriodValueImpl.create(DV, new DateValueImpl(2005, 2, 16)),
                 PeriodValueImpl.createFromDuration(DV, ONE_DAY));
    assertEquals(PeriodValueImpl.create(DV, new DateValueImpl(2005, 2, 22)),
                 PeriodValueImpl.createFromDuration(DV, ONE_WEEK));
    assertEquals(PeriodValueImpl.create(DV, new DateValueImpl(2005, 3, 15)),
                 PeriodValueImpl.createFromDuration(DV, ONE_MONTH));
    assertEquals(PeriodValueImpl.create(DV, new DateValueImpl(2006, 2, 15)),
                 PeriodValueImpl.createFromDuration(DV, ONE_YEAR));
    try {
      PeriodValueImpl.createFromDuration(DV, YESTERDAY);
      fail("I believe our adventures in time have taken a most serious turn.");
    } catch (IllegalArgumentException ex) {
View Full Code Here

TOP

Related Classes of com.google.ical.values.DateValueImpl

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.