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








LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond) gets an instance of LocalDateTime from year, month, day, hour, minute, second and nanosecond.

Syntax

of has the following syntax.

public static LocalDateTime of(int year,   
                               int month,   
                               int dayOfMonth,   
                               int hour,   
                               int minute,   
                               int second,   
                               int nanoOfSecond)




Example

The following example shows how to use of.

import java.time.LocalDateTime;

public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014,12,21,10,20,30,200);
    
    System.out.println(a);
  }
}

The code above generates the following result.