Code example for SimpleTimeZone

Methods: setEndRule, setStartRule

0
        String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
        // if no ids were returned, something is wrong. get out. 
        if (ids.length == 0)
            System.exit(0);
     // create a Pacific Standard Time time zone 
        SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
 
        // set up rules for daylight savings time 
        pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
        pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
 
        // create a GregorianCalendar with the Pacific Daylight time zone 
        // and the current date and time 
        Calendar calendar = new GregorianCalendar(pdt);
        Date trialTime = new Date();
        calendar.setTime(trialTime);
         
        Date today = new Date();
        Date dateBirth = calendar.getTime();
         
        Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();