Java ZoneId check if Day light savings is in effect

Description

Java ZoneId check if Day light savings is in effect

import java.time.ZoneId;
import java.time.ZonedDateTime;

public class Main {
  public static void main(String[] args) {

    ZoneId arrivingZone = ZoneId.of("Asia/Tokyo");
    ZonedDateTime arrival = ZonedDateTime.now();

    if (arrivingZone.getRules().isDaylightSavings(arrival.toInstant()))
      System.out.printf("(%s daylight saving time will be in effect.)%n", arrivingZone);
    else/*from  ww  w  .j  a  v  a2  s  .co  m*/
      System.out.printf("(%s standard time will be in effect.)%n", arrivingZone);
  }
}



PreviousNext

Related