Code example for GregorianCalendar

Methods: equals, get, setTime

0
	public void test_ConstructorLjava_util_TimeZoneLjava_util_Locale() { 
		// Test for method java.util.GregorianCalendar(java.util.TimeZone, 
		// java.util.Locale) 
		Date date = new Date(2008,1,1);
		TimeZone.getDefault();
		GregorianCalendar gc1 = new GregorianCalendar(TimeZone
				.getTimeZone("EST"), Locale.JAPAN);
		gc1.setTime(date);
		GregorianCalendar gc2 = new GregorianCalendar(TimeZone
				.getTimeZone("EST"), Locale.JAPAN);
		gc2.setTime(date);
		GregorianCalendar gc3 = new GregorianCalendar(TimeZone
				.getTimeZone("CST"), Locale.ITALY);
		gc3.setTime(date);
		// CST is 1 hour before EST, add 1 to the CST time and convert to 0-12 
		// value 
		assertTrue("Incorrect calendar returned",
				gc1.get(Calendar.HOUR) == ((gc3.get(Calendar.HOUR) + 1) % 12));
		assertTrue("Locales not created correctly", gc1.equals(gc2)
				&& !gc1.equals(gc3));
	} 
 
	/** 
	 * @tests java.util.GregorianCalendar#add(int, int) 
	 */