Package java.util

Examples of java.util.GregorianCalendar.roll()


        assertEquals("Wrong year: " + cal.getTime(), 1999, cal
                .get(Calendar.YEAR));
        assertEquals("Wrong month: " + cal.getTime(), Calendar.JANUARY, cal
                .get(Calendar.MONTH));
        assertEquals("Wrong date: " + cal.getTime(), 8, cal.get(Calendar.DATE));
        cal.roll(GregorianCalendar.WEEK_OF_YEAR, false);
        assertEquals("Wrong year: " + cal.getTime(), 1999, cal
                .get(Calendar.YEAR));
        assertEquals("Wrong month: " + cal.getTime(), Calendar.DECEMBER, cal
                .get(Calendar.MONTH));
        assertEquals("Wrong date: " + cal.getTime(), 31, cal.get(Calendar.DATE));
View Full Code Here


   */
  public void test_rollII() {
    // Test for method void java.util.GregorianCalendar.roll(int, int)
    GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8,
        2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, -1);
    assertTrue("Failed to roll DAY_OF_MONTH down by 1", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 7, 2, 5,
            0)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8, 2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, 25);
View Full Code Here

    gc.roll(Calendar.DAY_OF_MONTH, -1);
    assertTrue("Failed to roll DAY_OF_MONTH down by 1", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 7, 2, 5,
            0)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8, 2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, 25);
    assertTrue("Failed to roll DAY_OF_MONTH up by 25", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 2, 2, 5,
            0)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8, 2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, -10);
View Full Code Here

    gc.roll(Calendar.DAY_OF_MONTH, 25);
    assertTrue("Failed to roll DAY_OF_MONTH up by 25", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 2, 2, 5,
            0)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 8, 2, 5, 0);
    gc.roll(Calendar.DAY_OF_MONTH, -10);
    assertTrue("Failed to roll DAY_OF_MONTH down by 10", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 29, 2, 5,
            0)));
  }
View Full Code Here

   */
  public void test_rollIZ() {
    // Test for method void java.util.GregorianCalendar.roll(int, boolean)
    GregorianCalendar gc = new GregorianCalendar(1972, Calendar.OCTOBER,
        13, 19, 9, 59);
    gc.roll(Calendar.DAY_OF_MONTH, false);
    assertTrue("Failed to roll day_of_month down", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 12, 19,
            9, 59)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 13, 19, 9, 59);
    gc.roll(Calendar.DAY_OF_MONTH, true);
View Full Code Here

    gc.roll(Calendar.DAY_OF_MONTH, false);
    assertTrue("Failed to roll day_of_month down", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 12, 19,
            9, 59)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 13, 19, 9, 59);
    gc.roll(Calendar.DAY_OF_MONTH, true);
    assertTrue("Failed to roll day_of_month up", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 14, 19,
            9, 59)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 31, 19, 9, 59);
    gc.roll(Calendar.DAY_OF_MONTH, true);
View Full Code Here

    gc.roll(Calendar.DAY_OF_MONTH, true);
    assertTrue("Failed to roll day_of_month up", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 14, 19,
            9, 59)));
    gc = new GregorianCalendar(1972, Calendar.OCTOBER, 31, 19, 9, 59);
    gc.roll(Calendar.DAY_OF_MONTH, true);
    assertTrue("Failed to roll day_of_month up", gc
        .equals(new GregorianCalendar(1972, Calendar.OCTOBER, 1, 19, 9,
            59)));

    GregorianCalendar cal = new GregorianCalendar();
View Full Code Here

            59)));

    GregorianCalendar cal = new GregorianCalendar();
    int result;
    try {
      cal.roll(Calendar.ZONE_OFFSET, true);
      result = 0;
    } catch (IllegalArgumentException e) {
      result = 1;
    }
    assertEquals("ZONE_OFFSET roll", 1, result);
View Full Code Here

    } catch (IllegalArgumentException e) {
      result = 1;
    }
    assertEquals("ZONE_OFFSET roll", 1, result);
    try {
      cal.roll(Calendar.DST_OFFSET, true);
      result = 0;
    } catch (IllegalArgumentException e) {
      result = 1;
    }
    assertEquals("ZONE_OFFSET roll", 1, result);
View Full Code Here

      result = 1;
    }
    assertEquals("ZONE_OFFSET roll", 1, result);

    cal.set(2004, Calendar.DECEMBER, 31, 5, 0, 0);
    cal.roll(Calendar.WEEK_OF_YEAR, true);
        assertEquals("Wrong year: " + cal.getTime(), 2004, cal
                .get(Calendar.YEAR));
        assertEquals("Wrong month: " + cal.getTime(), Calendar.JANUARY, cal
                .get(Calendar.MONTH));
        assertEquals("Wrong date: " + cal.getTime(), 9, cal.get(Calendar.DATE));
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.