java.time.OffsetTime.atDate() Method Example



Description

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

Declaration

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

public OffsetDateTime atDate(LocalDate date)

Parameters

date − the date to combine with, not null.

Return Value

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

Example

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

package com.tutorialspoint;

import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.OffsetTime;

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

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

      OffsetTime time = OffsetTime.parse("12:30:30+01:00");
      OffsetDateTime datetime = time.atDate(date);
      System.out.println(datetime);  
   }
}

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

2017-03-21
2017-03-21T12:30:30+01:00
Advertisements