public String getLastMonth() {
SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date); // 设置为当前时间
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); // 设置为上一个月
date = calendar.getTime();
String accDate = format.format(date);
return accDate;
}
Java获取当前月的上一个月
最新推荐文章于 2024-08-26 01:08:10 发布