1、获取本月的第一天
2、获取本月的最后一条
//获取本月的第一天
private String getFirstDay(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); Date date = new Date(); System.out.println(date); return sdf.format(date)+"-01"; } /** * 获取本月最后一天 * */ private String getLastDay(){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); int month = calendar.get(Calendar.MONTH); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DAY_OF_MONTH,calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); Date strDateTo = calendar.getTime(); return sdf.format(strDateTo); }