OffsetDateTime of(LocalDateTime dateTime, ZoneOffset offset) example
Description
OffsetDateTime of(LocalDateTime dateTime, ZoneOffset offset)
creates
an instance of OffsetDateTime from a date-time and offset.
Syntax
of
has the following syntax.
public static OffsetDateTime of(LocalDateTime dateTime, ZoneOffset offset)
Example
The following example shows how to use of
.
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
/* w w w .ja va2 s. co m*/
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.