Java Date Time - Instant atOffset(ZoneOffset offset) example








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;
//from   www  .  ja  v a 2 s.co m
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.