Instant atOffset(ZoneOffset offset) example

Description

Instant atOffset(ZoneOffset offset) combines this instant 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.Instant;
import java.time.ZoneOffset;
//w w w .  j  a  v a 2s  .c  om
public class Main {
  public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    System.out.println(instant.atOffset(ZoneOffset.UTC));
 
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset