Java Date Time Java Java API
java.time.ZonedDateTime
public ZonedDateTime withDayOfMonth(int dayOfMonth)
Returns a copy of this ZonedDateTime with the day-of-month replaced with the provided 'dayOfMonth'
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); }}
2017-05-01T16:00:24.211-05:00[America/Chicago]2017-05-30T16:00:24.211-05:00[America/Chicago]