项目中的统计是以每个月的26号进行结算,所以默认值设置为 上月26号 和 当月26号 (如:2014-07-26 和 2014-08-26之间)
jsp代码:
<%
Calendar date = Calendar.getInstance();
int year = date.get(Calendar.YEAR);
int month = date.get(Calendar.MONTH);
String dateMax = "";
String dateMin = "";
if(month==0){
System.out.println(" if month==0,"+ month);
dateMax = year+"-01-26";
year = year -1;
dateMin = year+"-12-26";
}else if(month == 12){
System.out.println(" if month==12,"+ month);
dateMax = year+"-02-26";
dateMin = year+"-01-26";
}else if(month == 9 || month ==10 || month == 11){
System.out.println(" if month==9,10,11,"+ month);
dateMax = year+"-"+(month+1)+"-26";
dateMin = year+"-"+month+"-26";
}else{
System.out.println("else,"+ month);
dateMax = year+"-0"+(month+1)+"-26";
dateMin = year+"-0"+month+"-26";
}
request.setAttribute("dateMin",dateMin);
request.setAttribute("dateMax",dateMax);
%>
<s:textfield id="dlyDateMin" value="%{#request.dateMin}" />
至
<s:textfield id="dlyDateMax" value="%{#request.dateMax}"/>