Java Date Time Java Java API
java.time.OffsetTime
public OffsetTime withOffsetSameLocal(ZoneOffset offset)
This method returns a copy of OffsetTime representing the same LocalTime but with offset part adjusted to the provided zone offset.
package com.logicbig.example.offsettime;import java.time.OffsetTime;import java.time.ZoneOffset;public class WithOffsetSameLocalExample { public static void main(String... args) { OffsetTime t = OffsetTime.now(); System.out.println(t); OffsetTime t2 = t.withOffsetSameLocal(ZoneOffset.ofHours(4)); System.out.println(t2); }}
18:30:26.724+08:0018:30:26.724+04:00