Close

Java Date Time - ZoneOffset.adjustInto() Examples

Java Date Time Java Java API 


Class:

java.time.ZoneOffset

java.lang.Objectjava.lang.Objectjava.time.ZoneIdjava.time.ZoneIdjava.io.SerializableSerializablejava.time.ZoneOffsetjava.time.ZoneOffsetjava.time.temporal.TemporalAccessorTemporalAccessorjava.time.temporal.TemporalAdjusterTemporalAdjusterjava.lang.ComparableComparablejava.io.SerializableSerializableLogicBig

Method:

public Temporal adjustInto(Temporal temporal)

Adjusts the specified temporal object to have the same offset as this ZoneOffsetObject. The returned Temporal is of the same type as of the input temporal type.


Examples


package com.logicbig.example.zoneoffset;

import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.temporal.Temporal;

public class AdjustIntoExample {

public static void main(String... args) {
ZoneOffset z = ZoneOffset.ofHours(-7);
System.out.println(z);

OffsetDateTime d = OffsetDateTime.now();
Temporal t = z.adjustInto(d);
System.out.printf("%s > %s%n", d, t);
}
}

Output

-07:00
2017-05-01T15:50:47.348-05:00 > 2017-05-01T15:50:47.348-07:00




See Also