Java Date Time - Instant adjustInto(Temporal temporal) example








Instant adjustInto(Temporal temporal) adjusts the specified temporal object to have this instant.

Syntax

adjustInto has the following syntax.

public Temporal adjustInto(Temporal temporal)

Example

The following example shows how to use adjustInto.

import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.temporal.Temporal;
//from w  w w.  j  a  v a 2 s . c  o m
public class Main {
  public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    ZonedDateTime l = ZonedDateTime.now();
    Temporal t = instant.adjustInto(l);
    System.out.println((ZonedDateTime)t);
 
  }
}

The code above generates the following result.