OffsetDateTime atZoneSimilarLocal(ZoneId zone)
combines this date-time with a time-zone to create a ZonedDateTime trying to
keep the same local date and time.
atZoneSimilarLocal
has the following syntax.
public ZonedDateTime atZoneSimilarLocal(ZoneId zone)
The following example shows how to use atZoneSimilarLocal
.
import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; /*from w ww.j a va 2 s . c om*/ public class Main { public static void main(String[] args) { OffsetDateTime o = OffsetDateTime.now(); ZonedDateTime d = o.atZoneSimilarLocal(ZoneId.systemDefault()); System.out.println(d); } }
The code above generates the following result.