Calendar calendar = Calendar.getInstance();
// 获得日历对象
calendar.setTime(new Date());
// 先设置为当前时间
calendar.add(Calendar.DAY_OF_YEAR, -1);
// 再次设置日历时间
Date bf = new Date();
bf = calendar.getTime();
// 新的日期对象并获取日历的时间
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
// 设置时间的格式
String s = format.format(bf);
//转换为字符串格式
JAVA求前一天的日期
最新推荐文章于 2021-02-25 16:56:59 发布