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








LocalDateTime of(int year, Month month, int dayOfMonth, int hour, int minute, int second) gets an instance of LocalDateTime from year, month, day, hour, minute and second, setting the nanosecond to zero.

Syntax

of has the following syntax.

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




Example

The following example shows how to use of.

import java.time.LocalDateTime;
import java.time.Month;
/*w w w. j a  v  a2 s. c  om*/
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014,Month.MARCH,21,10,20);
    
    System.out.println(a);
  }
}

The code above generates the following result.