ZonedDateTime withZoneSameInstant(ZoneId zone)
returns a copy of this
date-time with a different time-zone, retaining the instant.
withZoneSameInstant
has the following syntax.
public ZonedDateTime withZoneSameInstant(ZoneId zone)
The following example shows how to use withZoneSameInstant
.
import java.time.ZoneId; import java.time.ZonedDateTime; /*w w w. j av a 2 s . co 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.