Calendar 取上一年,上个月日期
作者:互联网
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH,-12);//上一年
//cal.add(Calendar.MONTH,-1);//上个月
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String day = sdf.format(cal.getTime());
System.out.println(day);//2020-09-24
标签:上个月,上一年,SimpleDateFormat,add,cal,Calendar,sdf,day 来源: https://blog.csdn.net/weixin_43474476/article/details/120457370