Created
June 10, 2021 17:01
-
-
Save superzjn/e65bfae3290692077dc09dffca962393 to your computer and use it in GitHub Desktop.
[Date After a week or a year]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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