标签:public alt yesterday body nta Oday 功能 打印 相同
在Java 8中,可以用下面的代码实现相同的功能。
1
2
3
4
5
6
7
8
9
10
11
|
import java.time.LocalDateTime; class YesterdayCurrent { public static void main(String[] args) { LocalDateTime today = LocalDateTime.now(); LocalDateTime yesterday = today.minusDays( 1 ); System.out.println(yesterday); } } |
1
2
3
4
5
6
7
8
9
|
import java.util.Calendar; class YesterdayCurrent { public static void main(String[] args){ Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, - 1 ); System.out.println(cal.getTime()); } } |
标签:public alt yesterday body nta Oday 功能 打印 相同
原文地址:https://www.cnblogs.com/gjack/p/8901459.html