求当前月的第一天和最后一天
/**
* 获取当前月的第一天和最后一个天 输出:20160201000000 20160229235959
*/
public Map<String, Object> getCurrentMonthfirstAndEndDay() {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
//获取当前月第一天:
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, 0);
c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
c.set(Calendar.HOUR_OF_DAY,0);
c.set(Calendar.MINUTE,0);
c.set(Calendar.SECOND,0);
String first = format.format(c.getTime());
logger.debug("===============当月的第一天"+first); //20160201000000
//获取当前月最后一天
Calendar ca = Calendar.getInstance();
ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
ca.set(Calendar.HOUR_OF_DAY,23);
ca.set(Calendar.MINUTE,59);
ca.set(Calendar.SECOND,59);
String last = format.format(ca.getTime());
logger.debug("===============当月的最后一天"+last); //20160229235959
//取当前月
Map<String, Object> firstAndEndDayMap = new HashMap<String, Object>();
firstAndEndDayMap.put("firstDay", first);
firstAndEndDayMap.put("endDay", last);
return firstAndEndDayMap;
}