Java ZonedDatetime class

Introduction

Java ZonedDateTime class represents a date time with time zone rules.

import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneId;
import java.time.ZonedDateTime;

public class Main {
  public static void main(String[] args) {
    ZoneId usCentral = ZoneId.of("America/Chicago");
    LocalDateTime ldt = LocalDateTime.of(2020, Month.MAY, 11, 7, 30);
    ZonedDateTime zdt = ZonedDateTime.of(ldt, usCentral);
    System.out.println(zdt);/*from   w ww .j  a v  a2  s .  co  m*/
  }
}



PreviousNext

Related