java获取当前月的上个月
作者:互联网
/** * 获取当前月的上一个月 * @return */ public static String getLastMonth() { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); Date date = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); // 设置为当前时间 calendar.add(Calendar.MONTH,-1); date = calendar.getTime(); String accDate = format.format(date); return accDate; }
标签:java,String,format,SimpleDateFormat,获取,上个月,date,calendar,Calendar 来源: https://www.cnblogs.com/huatian007/p/16325067.html