The atDate() method of OffsetTime class in Java combines this time with a date to create a OffsetDateTime.
Syntax :
public OffsetDateTime atDate(LocalDate date)
Parameter: This method accepts a single parameter date which specifies the date to combine with, not null.
Return Value: It returns the OffsetDateTime formed from this time and the specified date, not null
Below programs illustrate the atDate() method:
Program 1 :
// Java program to demonstrate the atDate() method import java.time.LocalDate; import java.time.OffsetDateTime; import java.time.OffsetTime; public class GFG { public static void main(String[] args) { // parses the current date LocalDate date = LocalDate.now(); System.out.println("Current date: " + date); // Parses the current time OffsetTime time = OffsetTime.parse("11:10:10+06:03"); OffsetDateTime datetime = time.atDate(date); System.out.println("Current date and time: " + datetime); } } |
Current date: 2018-12-31 Current date and time: 2018-12-31T11:10:10+06:03
Program 2 :
// Java program to demonstrate the atDate() method import java.time.LocalDate; import java.time.OffsetDateTime; import java.time.OffsetTime; public class GFG { public static void main(String[] args) { // parses the current date LocalDate date = LocalDate.now(); System.out.println("Current date: " + date); // Parses the current time OffsetTime time = OffsetTime.parse("12:15:14+16:03"); OffsetDateTime datetime = time.atDate(date); System.out.println("Current date and time: " + datetime); } } |
Current date: 2018-12-31 Current date and time: 2018-12-31T12:15:14+16:03
Reference: https://docs.oracle.com/javase/8/docs/api/java/time/OffsetTime.html#atDate-java.time.LocalDate-
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- LocalTime atDate() method in Java with Examples
- OffsetTime plus() method in Java with examples
- OffsetTime from() method in Java with examples
- OffsetTime of() method in Java with Examples
- OffsetTime until() Method in Java with Examples
- OffsetTime get() method in Java with examples
- OffsetTime now() method in Java with examples
- OffsetTime with() Method in Java with Examples
- OffsetTime getMinute() method in Java with examples
- OffsetTime getNano() method in Java with examples
- OffsetTime toLocalTime() method in Java with examples
- OffsetTime getHour() method in Java with examples
- OffsetTime minusHours() method in Java with examples
- OffsetTime adjustInto() method in Java with examples
- OffsetTime toString() method in Java with examples
- OffsetTime range() method in Java with Examples
- OffsetTime plusNanos() method in Java with Examples
- OffsetTime query() method in Java with examples
- OffsetTime plusMinutes() method in Java with examples
- OffsetTime minusSeconds() method in Java with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

