Skip to content

Instantly share code, notes, and snippets.

@superzjn
Created June 10, 2021 17:01
Show Gist options
  • Save superzjn/e65bfae3290692077dc09dffca962393 to your computer and use it in GitHub Desktop.
Save superzjn/e65bfae3290692077dc09dffca962393 to your computer and use it in GitHub Desktop.
[Date After a week or a year]
package com.shxt.demo02;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
public class Demo09 {
public static void main(String[] args) {
LocalDate today = LocalDate.now();
LocalDate previousYear = today.minus(1, ChronoUnit.YEARS);
System.out.println("一年前的日期 : " + previousYear);
LocalDate nextYear = today.plus(1, ChronoUnit.YEARS);
System.out.println("一年后的日期:"+nextYear);
LocalDate today = LocalDate.now();
System.out.println("今天的日期为:"+today);
LocalDate nextWeek = today.plus(1, ChronoUnit.WEEKS);
System.out.println("一周后的日期为:"+nextWeek);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment