Code example for GregorianCalendar

Methods: equals, roll

0
	/** 
	 * @tests java.util.GregorianCalendar#roll(int, int) 
	 */ 
	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); 
		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)));