OffsetTime withOffsetSameInstant( ZoneOffset offset) example
Description
OffsetTime withOffsetSameInstant(ZoneOffset offset)
returns a copy of this OffsetTime with the specified offset
ensuring that the result is at the same instant on an implied day.
Syntax
withOffsetSameInstant
has the following syntax.
public OffsetTime withOffsetSameInstant(ZoneOffset offset)
Example
The following example shows how to use withOffsetSameInstant
.
import java.time.OffsetTime;
import java.time.ZoneOffset;
//from w w w . ja v a 2 s. com
public class Main {
public static void main(String[] args) {
OffsetTime m = OffsetTime.now();
OffsetTime l = m.withOffsetSameInstant(ZoneOffset.UTC);
System.out.println(l);
}
}
The code above generates the following result.