Code example for SimpleTimeZone

Methods: setEndRule, setStartRule

0
		String[] ids = TimeZone.getAvailableIDs(-5 * 60 * 60 * 1000);
		if (ids.length == 0) {
			System.out.println("FAILURE ON TIME GET!!!");
			System.exit(0);
		} 
		SimpleTimeZone pdt = new SimpleTimeZone(-5 * 60 * 60 * 1000, ids[0]);
		pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
		pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY,
				2 * 60 * 60 * 1000); 
 
		Calendar calendar = new GregorianCalendar(pdt);
 
		Date currentDate = new Date();
		calendar.setTime(currentDate);
		java.text.SimpleDateFormat df2 = new java.text.SimpleDateFormat(
				"MM/dd/yyyy ' ' hh:mm:ss a"); 
		// System.out.println(df2.format(calendar.getTime())); 
		return (df2.format(calendar.getTime()));
	} 
 
	@Override