Instant adjustInto(Temporal temporal) example

Description

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;
/* w  w w.  ja v a  2s  .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.





















Home »
  Java Date Time »
    java.time Reference »




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