获取当月第一天和最后一天
JS 获取:
?
获取第一天
? ? var myDate = new Date();
? ? var year = myDate.getFullYear();
? ? var month = myDate.getMonth()+1;
? ? if (month<10){ month = "0"+month; }
? ? var firstDay = month+"/"+"01/"+year;
?
获取最后一天
? ? myDate = new Date(year,month,0);
? ? var lastDay = month+"/"+myDate.getDate()+"/"+year;
? ? var firstTime = "00:00:00";
? ? var lastTime = "23:59:59";
?
?
Java 获取:
?
? ? Calendar curCal = Calendar.getInstance();
? ? SimpleDateFormat datef;
?
获取第一天
? ? curCal.set(Calendar.DATE, 1);
? ? curCal.roll(Calendar.DATE, -1);
? ? Date endTime = curCal.getTime();
? ? String eTime = datef.format(endTime) + " 23:59:59";
?
获取最后一天
? ? curCal.set(Calendar.DAY_OF_MONTH, 1);
? ? Date beginTime = curCal.getTime();
? ? String sTime = datef.format(beginTime) + " 00:00:00";