ZonedDateTime withZoneSameInstant(ZoneId zone) example
Description
ZonedDateTime withZoneSameInstant(ZoneId zone)
returns a copy of this
date-time with a different time-zone, retaining the instant.
Syntax
withZoneSameInstant
has the following syntax.
public ZonedDateTime withZoneSameInstant(ZoneId zone)
Example
The following example shows how to use withZoneSameInstant
.
import java.time.ZoneId;
import java.time.ZonedDateTime;
// w ww . java2 s . c o m
public class Main {
public static void main(String[] args) {
ZonedDateTime dateTime =ZonedDateTime.now();
ZonedDateTime l =dateTime.withZoneSameInstant(ZoneId.systemDefault()) ;
System.out.println(l);
}
}
The code above generates the following result.