Java Time/LocalDateTime (Java 8): Add Days or Add Minutes

May 17, 2019

Java

LocalDateTime now = LocalDateTime.now()
now = now.addDays(1)

NOTE: Java 8 Date Time is immutable, thus we need to perform the reassignment.

LocalTime now = LocalTime.now()
now = now.plusMinutes(1)

Kotlin

var now = LocalDateTime.now()
now = now.plusDays(1)
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.