Close

Java Date Time - OffsetTime.atDate() Examples

Java Date Time Java Java API 


Class:

java.time.OffsetTime

java.lang.Objectjava.lang.Objectjava.time.OffsetTimejava.time.OffsetTimejava.time.temporal.TemporalTemporaljava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public OffsetDateTime atDate(LocalDate date)

Combines this OffsetTime with the provided LocalDate and returns a new OffsetDateTime.


Examples


package com.logicbig.example.offsettime;

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

public class AtDateExample {

public static void main(String... args) {
OffsetTime t = OffsetTime.of(17, 40, 33, 20000, ZoneOffset.ofHours(-6));
System.out.println(t);

LocalDate d = LocalDate.of(2015, 11, 2);
System.out.println(d);

OffsetDateTime offsetDateTime = t.atDate(d);
System.out.println(offsetDateTime);
}
}

Output

17:40:33.000020-06:00
2015-11-02
2015-11-02T17:40:33.000020-06:00




package com.logicbig.example.offsettime;

import java.time.*;

public class AtDateExample2 {

public static void main(String... args) {
OffsetTime t = OffsetTime.of(LocalTime.NOON, ZoneOffset.of("-06:00"));
System.out.println(t);

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

OffsetDateTime offsetDateTime = t.atDate(d);
System.out.println(offsetDateTime);
}
}

Output

12:00-06:00
2017-05-01
2017-05-01T12:00-06:00




See Also