Code example for TimeZone

Methods: inDaylightTime

0
    private Date computeAdjustedTime(Date initialDate, TimeZone targetTZ, boolean adjustToDayStart) { 
        Calendar cal = Calendar.getInstance(); 
        cal.setTime(initialDate); 
        TimeZone localTZ = cal.getTimeZone(); 
        int timezoneOffset = cal.get(Calendar.ZONE_OFFSET); 
        if (localTZ.inDaylightTime(initialDate)) { 
            timezoneOffset += (60 * 60 * 1000); 
        } 
        cal.add(Calendar.MILLISECOND, timezoneOffset); 
 
        Date newTime = cal.getTime(); 
 
        Calendar calTS = Calendar.getInstance(targetTZ); 
        calTS.setTime(newTime); 
        timezoneOffset = calTS.get(Calendar.ZONE_OFFSET); 
        if (targetTZ.inDaylightTime(initialDate)) { 
            timezoneOffset += (60 * 60 * 1000); 
        } 
 
        calTS.add(Calendar.MILLISECOND, -1*timezoneOffset); 
Connect your IDE to all the code out there  Get Codota for Java