Close

Java Date Time - ZonedDateTime.withDayOfMonth() Examples

Java Date Time Java Java API 


Class:

java.time.ZonedDateTime

java.lang.Objectjava.lang.Objectjava.time.ZonedDateTimejava.time.ZonedDateTimejava.time.temporal.TemporalTemporaljava.time.chrono.ChronoZonedDateTimeChronoZonedDateTimejava.io.SerializableSerializableLogicBig

Method:

public ZonedDateTime withDayOfMonth(int dayOfMonth)

Returns a copy of this ZonedDateTime with the day-of-month replaced with the provided 'dayOfMonth'

Examples


package com.logicbig.example.zoneddatetime;

import java.time.ZonedDateTime;

public class WithDayOfMonthExample {

public static void main(String... args) {
ZonedDateTime d = ZonedDateTime.now();
System.out.println(d);

ZonedDateTime d2 = d.withDayOfMonth(30);
System.out.println(d2);
}
}

Output

2017-05-01T16:00:24.211-05:00[America/Chicago]
2017-05-30T16:00:24.211-05:00[America/Chicago]




See Also