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








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

Syntax

of has the following syntax.

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




Example

The following example shows how to use of.

import java.time.LocalDateTime;
import java.time.Month;
/* www  . j  a  v a  2s .  co  m*/
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.