I am trying to find out the day light saving start time in US which is 14th March 2021 at 2:00 AM but my code is returning the 14th March 2021 at 3:00 AM. I am not able to understand this one hour time difference. My code is listed below:
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.time.zone.ZoneOffsetTransition;
import java.time.zone.ZoneRules;
class DST{
public static void main(String[] args) {
ZoneId zoneId = ZoneId.of("America/New_York");
ZoneRules rules = zoneId.getRules();
ZoneOffsetTransition nextTransition = rules.nextTransition(Instant.now());
Timestamp ts = Timestamp.valueOf(nextTransition.getInstant().atZone(zoneId).toLocalDateTime());
SimpleDateFormat sdf = new SimpleDateFormat("MMMM d, yyyy 'at' h:mm a");
String date = sdf.format(ts);
system.out.println("DST time:"+ date );
}
}
The date value is come as March 14, 2021 at 3:00 AM
but it should be March 14, 2021 at 2:00 AM
. I am not able to understand the difference of one hour time difference?