Java后台如何获取某个时间的上周一和上周五,首先在ibatis里面获取对应字段的起止时间;

<isNotEmpty prepend=” and ” property=”lrsjq”>
<![CDATA[lrsj >= to_date(#lrsjq#, ‘yyyy-MM-dd’)]]>
</isNotEmpty>
<isNotEmpty prepend=” and ” property=”lrsjz”>
<![CDATA[lrsj<= to_date(#lrsjz#, ‘yyyy-MM-dd’)]]>
</isNotEmpty>
接着在action里面加入
public String query() {
user = (AppUser) getSession().getAttribute(“_userInfo”);
Map pm = new HashMap();
Calendar cal = Calendar.getInstance();
Calendar cal1 = Calendar.getInstance();
int n = -1;
String monday;
cal.add(Calendar.DATE, n*7);
cal1.add(Calendar.DATE, n*7);
//想周几,这里就传几Calendar.MONDAY(TUESDAY…)
cal.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
cal1.set(Calendar.DAY_OF_WEEK,Calendar.SATURDAY);
lrsjq= new SimpleDateFormat(“yyyy-MM-dd”).format(cal.getTime());
lrsjz= new SimpleDateFormat(“yyyy-MM-dd”).format(cal1.getTime());
pm.put(“lrsjq”, lrsjq);
pm.put(“lrsjz”, lrsjz);
return SUCCESS;
}