java 获取当前日期之前多少天是什么日期

2024-11-10 23:44:32
推荐回答(1个)
回答1:

Calendar calendar = Calendar.getInstance();
//今天
System.out.println(calendar.getTime());
//10天前
calendar.add(Calendar.DATE, -10);
System.out.println(calendar.getTime());

Fri Oct 14 22:59:27 CST 2016

Tue Oct 04 22:59:27 CST 2016