Java Get Tomorrow LocalDate
Tags: Java LocalDate DateUtil
In this Java tutorial, we learn how to get tomorrow date and return it as a LocalDate object in Java programming language.
How to get tomorrow LocalDate in Java
At this first step, we create a new Java class named DateUtil, and implement a new static method named getTomorrowLocalDate() to get tomorrow LocalDate object as the following Java code.
DateUtil.java
import java.time.LocalDate;
public class DateUtil {
/**
* This method to get tomorrow date and return it as a LocalDate object.
* @return the tomorrow LocalDate object.
*/
public static LocalDate getTomorrowLocalDate() {
LocalDate today = LocalDate.now();
LocalDate tomorrow = today.plusDays(1);
return tomorrow;
}
}
In the following example Java code, we learn how to use the above getTomorrowLocalDate() method to get yesterday as a LocalDate object in Java program.
GetTomorrowLocalDateExample.java
import java.time.LocalDate;
public class GetTomorrowLocalDateExample {
public static void main(String... args) {
// Get Tomorrow LocalDate
LocalDate tomorrow = DateUtil.getTomorrowLocalDate();
System.out.println("Today: " + LocalDate.now());
System.out.println("Tomorrow: " + tomorrow);
}
}
Today: 2022-08-20
Tomorrow: 2022-08-21
Happy Coding 😊