Java Date Time - ZonedDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond, ZoneId zone) example








ZonedDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond, ZoneId zone) creates an instance of ZonedDateTime from a year, month, day, hour, minute, second, nanosecond and time-zone.

Syntax

of has the following syntax.

public static ZonedDateTime of(int year,   
                               int month,   
                               int dayOfMonth,   
                               int hour,   
                               int minute,   
                               int second,   
                               int nanoOfSecond,   
                               ZoneId zone)




Example

The following example shows how to use of.

import java.time.ZoneId;
import java.time.ZonedDateTime;
//  w w  w  .  j a  va  2s  .  c o  m
public class Main {
  public static void main(String[] args) {
    ZonedDateTime z = ZonedDateTime.of(2014,9,3,12,12,123,1234,ZoneId.systemDefault());
    
    System.out.println(z);

  }
}