項目中的統計是以每個月的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}"/>