LocalDateTime adjustInto(Temporal temporal) example

Description

LocalDateTime adjustInto(Temporal temporal) adjusts the specified temporal object to have the same date and time as this object.

Syntax

adjustInto has the following syntax.


public Temporal adjustInto(Temporal temporal)

Example

The following example shows how to use adjustInto.


import java.time.LocalDateTime;
import java.time.temporal.Temporal;
//from w w w . j  a  v a2  s. c  o  m
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);
    LocalDateTime b = LocalDateTime.now();
    
    Temporal t = a.adjustInto(b);
    
    System.out.println(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