OffsetDateTime of(LocalDateTime dateTime, ZoneOffset offset)
creates
an instance of OffsetDateTime from a date-time and offset.
of
has the following syntax.
public static OffsetDateTime of(LocalDateTime dateTime, ZoneOffset offset)
The following example shows how to use of
.
import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; /* w w w . j av a2s.c om*/ public class Main { public static void main(String[] args) { OffsetDateTime o = OffsetDateTime.of(LocalDateTime.now(), ZoneOffset.UTC); System.out.println(o); } }
The code above generates the following result.