How to find next, previous, tomorrow ,yesterday date using Java 8
Categories: Java 8(JDK1.8) Java Java Examples
package r4r.co.in;
import java.time.LocalDate;
public class FindTodayTommrowYesterdayUsingJava8 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//How to find next/previous(tomorrow/yesterday) date using Java 8?
LocalDate date = LocalDate.now();
System.out.println("Today :- " + date);
System.out.println("Yesterday :- " + date.minusDays(1));
System.out.println("Tommorrow :- " + date.plusDays(1));
}
}
OutPut:-
Today :- 2024-08-29
Yesterday :- 2024-08-28
Tommorrow :- 2024-08-30