Example usage for java.time LocalDateTime withDayOfMonth

List of usage examples for java.time LocalDateTime withDayOfMonth

Introduction

In this page you can find the example usage for java.time LocalDateTime withDayOfMonth.

Prototype

public LocalDateTime withDayOfMonth(int dayOfMonth) 

Source Link

Document

Returns a copy of this LocalDateTime with the day-of-month altered.

Usage

From source file:Main.java

public static void main(String[] args) {

    LocalDateTime timePoint = LocalDateTime.now();
    LocalDateTime thePast = timePoint.withDayOfMonth(10).withYear(2010);

    System.out.println(thePast);/*  w  w w .j a  v  a 2s  . c  o m*/
}

From source file:Main.java

public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01);

    LocalDateTime t = a.withDayOfMonth(20);

    System.out.println(t);//from w w w .  j  ava  2 s.co m
}