OffsetTime withOffsetSameLocal(ZoneOffset offset)
returns a copy of this OffsetTime with the specified offset ensuring that the result has the same local time.
withOffsetSameLocal
has the following syntax.
public OffsetTime withOffsetSameLocal(ZoneOffset offset)
The following example shows how to use withOffsetSameLocal
.
import java.time.OffsetTime; import java.time.ZoneOffset; /*from w w w. java2 s . com*/ 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.