OffsetTime withOffsetSameLocal(ZoneOffset offset) example
Description
OffsetTime withOffsetSameLocal(ZoneOffset offset)
returns a copy of this OffsetTime with the specified offset ensuring that the result has the same local time.
Syntax
withOffsetSameLocal
has the following syntax.
public OffsetTime withOffsetSameLocal(ZoneOffset offset)
Example
The following example shows how to use withOffsetSameLocal
.
import java.time.OffsetTime;
import java.time.ZoneOffset;
//from www.j a va 2 s .co m
public class Main {
public static void main(String[] args) {
OffsetTime m = OffsetTime.now();
OffsetTime l = m.withOffsetSameLocal(ZoneOffset.UTC);
System.out.println(l);
}
}
The code above generates the following result.