<%
//当前月的最后一天
cal.add( cal.MONTH,1 );
cal.set(cal.DATE,1);
cal.add(cal.DATE,-1);
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd");
String day_end=df.format(cal.getTime());
//当前月的第一天
GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
gc.setTime(date);
gc.set(Calendar.DAY_OF_MONTH, 1);
String day_first = df.format(gc.getTime());
//out.println(day_first);
//获取下月
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.MONTH, 1);
Date theDate = calendar.getTime();
String strDateDay = new SimpleDateFormat("MM").format(theDate);
int int_strDateDay = Integer.parseInt(strDateDay);
String ttt = new SimpleDateFormat("yyyy-MM-dd").format(theDate);
String worktime = new SimpleDateFormat("yyyyMM").format(theDate);
//下月的第一天
gc.setTime(theDate);
gc.set(Calendar.DAY_OF_MONTH, 1);
String day_first_nextM = df.format(gc.getTime());
//下月的最后一天
calendar.add( cal.MONTH,1 );
calendar.set(cal.DATE,1);
calendar.add(cal.DATE,-1);
String day_end_nextM=df.format(calendar.getTime());
%>
java月份时间(第一天,最后一天)
最新推荐文章于 2024-08-16 10:31:27 发布