Get tomorrow's date in Java
Question:
How to get tomorrow's date in Java? Answer:
LocalDate today = LocalDate.now();
LocalDate tomorrow = today.plusDays(1);
// In string format
LocalDate today = LocalDate.now();
String tomorrow = (today.plusDays(1)).format(DateTimeFormatter.ISO_DATE);
Description:
Using the LocalDate
class - introduced in Java 8 - it is quite simple to get tomorrow's date. First, create today's date by creating a new LocalDate
using the now()
static method. Then simply add one day to the actual date using the plusDays
method and that's it.
You can format the result as you want using the format()
method and the appropriate DateTimeFormatter
.
Reference:
LocalDate plusDays reference
Share "How to get tomorrow's date in Java?"
Related snippets:
- Get the last Friday of a month in Java
- Get the first Monday of a month in Java
- Get the first day of the week in Java
- Get the first day of the current month in Java
- Get the last day of a month in Java
- Get the number of days between two dates in Java
- Get yesterday's date in Java
- Get tomorrow's date in Java
- Get actual date in Java
Tags:
tomorrow date, tomorrows date, next day date Technical term:
Get tomorrow's date in Java