LocalDateTime atOffset(ZoneOffset offset)
combines this date-time with an offset to create an OffsetDateTime.
atOffset
has the following syntax.
public OffsetDateTime atOffset(ZoneOffset offset)
The following example shows how to use atOffset
.
import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; //www . j ava 2 s . c om 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.