LocalDateTime of(date, time) method in Java with Examples Last Updated : 21 May, 2020 Comments Improve Suggest changes Like Article Like Report The of(LocalDate date, LocalTime time) method of LocalDateTime class in Java is used to obtain an instance of LocalDateTime using the two input parameters, date and time. Initially, two separate instances are created. One is of LocalDate type and the other one is of LocalTime type. Then these are merged to create a LocalDateTime. Syntax: public static LocalDateTime of(LocalDate date, LocalTime time) Parameters: This method accepts two parameters: date- It is of LocalDate type and represents the local date. time- It is of LocalTime type and represents the local time. Return Value: This method returns the localdate-time. Exceptions: This method does not throw any exception. Below programs illustrate the of(LocalDate date, LocalTime time) method in Java: Program 1: Java // Java program to demonstrate // LocalDateTime.of(LocalDate date, // LocalTime time) method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // Create LocalDate object // using LocalDate.of() method LocalDate date = LocalDate.of(2020, 5, 13); // Create LocalTime object // using LocalTime.of() method LocalTime time = LocalTime.of(6, 30); // Create LocalDateTime object LocalDateTime localdatetime = LocalDateTime.of(date, time); // Print full date and time System.out.println( "DateTime: " + localdatetime); } } Output: DateTime: 2020-05-13T06:30 Program 2: Java // Java program to demonstrate // LocalDateTime.of(LocalDate date, // LocalTime time) method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // Create LocalDate object // using LocalDate.of() method LocalDate date = LocalDate.of(2019, 12, 31); // Create LocalTime object // using LocalTime.of() method LocalTime time = LocalTime.of(6, 30, 45); // Create LocalDateTime object LocalDateTime localdatetime = LocalDateTime.of(date, time); // Print full date and time System.out.println( "DateTime: " + localdatetime); } } Output: DateTime: 2019-12-31T06:30:45 References: https://docs.oracle.com/javase/10/docs/api/java/time/LocalDateTime.html#of(java.time.LocalDate, java.time.LocalTime) Comment More infoAdvertise with us Next Article LocalDateTime toLocalTime() method in Java with Examples P pp_pankaj Follow Improve Article Tags : Java Java-LocalDateTime Java-Functions Practice Tags : Java Similar Reads LocalDateTime toLocalTime() method in Java with Examples The toLocalTime() method of LocalDateTime class is used to get the LocalTime representation of this LocalDateTime. This method is derived from the Object Class and behaves in the similar way. Syntax: public LocalTime toLocalTime() Parameter: This method takes no parameters. Returns: This method retu 1 min read LocalDateTime toString() method in Java with Examples The toString() method of LocalDateTime class is used to get the String representation of this LocalDateTime. This method is derived from the Object Class and behaves in the similar way. Syntax: public String toString() Parameter: This method takes no parameters. Returns: This method returns a String 1 min read LocalDateTime now() Method in Java with Examples In LocalDateTime class, there are three types of now() method depending upon the parameters passed to it. now() now() method of a LocalDateTime class used to obtain the current date-time from the system clock in the default time-zone.This method will return LocalDateTime based on system clock with d 2 min read OffsetDateTime of(LocalDateTime) method in Java with Examples The of(LocalDateTime dateTime, ZoneOffset offset) method of the OffsetDateTime class in Java is used to create an instance of OffsetDateTime from given instances of date-time and offset. This method creates an OffsetDateTime with the specified local date-time and offset. Syntax: public static Offset 2 min read LocalTime atDate() method in Java with Examples The atDate() method of a LocalTime class is used to combine this LocalTime Object with a LocalDate Object to create a LocalDateTime. All possible combinations of date and time are valid. Syntax: public LocalDateTime atDate(LocalDate date) Parameters: This method accepts a single parameter date which 1 min read LocalDateTime ofInstant() method in Java with Examples ofInstant(Instant instant, ZoneId zone) method of LocalDateTime class in Java is used to create an instance of LocalDateTime using an Instant and zone ID. These two parameters are passed to the method and method returns LocalDateTime on the basis of these two parameters. The calculation of the Local 2 min read Like