ZonedDateTime with(TemporalAdjuster adjuster) example

Description

ZonedDateTime with(TemporalAdjuster adjuster) returns an adjusted copy of this date-time.

Syntax

with has the following syntax.


public ZonedDateTime with(TemporalAdjuster adjuster)

Example

The following example shows how to use with.


import java.time.ZonedDateTime;
import java.time.temporal.TemporalAdjusters;
/*from  w  w  w . j a v  a 2s  . c  o m*/
public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime =ZonedDateTime.now();
    dateTime = dateTime.with(TemporalAdjusters.firstDayOfMonth());
    System.out.println(dateTime);
  } 
}

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