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

Description

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;
/*from  w w  w  . j  ava 2s. 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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset