1.获取当前年月
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM");
java.util.Date currTime = new java.util.Date();curTime = formatter.format(currTime);
2.获取当前年月的前一个月
Calendar cal = Calendar.getInstance();
// cal.add(Calendar.DATE, -1); //得到前一天
cal.add(Calendar.MONTH, -1); // 得到前一个月long l_date = cal.getTimeInMillis();
Date date = new Date(l_date);
String cur = formatter.format(date);
3.获取当前年月的前一个月的第一天和最后一天的日期
Calendar curCal = Calendar.getInstance();
String end = DateUtil.getLastDayOfMonth(curCal.get(Calendar.YEAR), curCal.get(Calendar.MONTH));
String start = DateUtil.getFirstDayOfMonth(curCal.get(Calendar.YEAR), curCal.get(Calendar.MONTH));
4.获取当前时间
new Timestamp(new Date().getTime())