LocalDateTime atOffset(ZoneOffset offset) example
Description
LocalDateTime atOffset(ZoneOffset offset)
combines this date-time with an offset to create an OffsetDateTime.
Syntax
atOffset
has the following syntax.
public OffsetDateTime atOffset(ZoneOffset offset)
Example
The following example shows how to use atOffset
.
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
/* w w w .j a v a 2 s . c o m*/
public class Main {
public static void main(String[] args) {
LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);
OffsetDateTime b = a.atOffset(ZoneOffset.UTC);
System.out.println(b);
}
}
The code above generates the following result.