java.time.LocalTime.atDate() Method Example



Description

The java.time.LocalTime.atDate(LocalDate date) method combines this time with a date to create a LocalDateTime.

Declaration

Following is the declaration for java.time.LocalTime.atDate(LocalDate date) method.

public LocalDateTime atDate(LocalDate date)

Parameters

date − the date to combine with, not null.

Return Value

the local date-time formed from this time and the specified date, not null.

Example

The following example shows the usage of java.time.LocalTime.atDate(LocalDate date) method.

package com.tutorialspoint;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class LocalTimeDemo {
   public static void main(String[] args) {

      LocalDate date = LocalDate.now();
      System.out.println(date);  

      LocalTime time = LocalTime.parse("12:30:30");
      LocalDateTime datetime = time.atDate(date);
      System.out.println(datetime);  
   }
}

Let us compile and run the above program, this will produce the following result −

2017-03-20
2017-03-20T12:30:30
Advertisements