ZonedDateTime ofInstant(Instant instant, ZoneId zone)
creates
an instance of ZonedDateTime from an Instant.
ofInstant
has the following syntax.
public static ZonedDateTime ofInstant(Instant instant, ZoneId zone)
The following example shows how to use ofInstant
.
import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; /*w w w.j av a2 s . c om*/ public class Main { public static void main(String[] args) { ZonedDateTime z = ZonedDateTime.ofInstant(Instant.now(),ZoneId.systemDefault()); System.out.println(z); } }
The code above generates the following result.