Java后台如何获取时间段的所有季度,这里给出详细的解决方法,希望送给有这方面需求的朋友。

首先在ibatis里面,获取对应字段的年份nf、月份yf、开始月ks、结束月js;

<isNotEmpty prepend=” and ” property=”nf”>
<![CDATA[ #nf# = extract(year from khsj) ]]>
</isNotEmpty>
<isNotEmpty prepend=” and ” property=”yf”>
<![CDATA[ #yf# = extract(month from khsj) ]]>
</isNotEmpty>
<isNotEmpty prepend=” and ” property=”ks”>
<![CDATA[ #ks# <= extract(month from khsj) ]]>
</isNotEmpty>
<isNotEmpty prepend=” and ” property=”js”>
<![CDATA[ #js# >= extract(month from khsj) ]]>
</isNotEmpty>

接着在Action里面加入

private String jd;//季度

private String ks;//开始月

private String js;//结束月

public String queryXxx() {

user = (AppUser) getSession().getAttribute(“_userInfo”);

Map pm = new HashMap();

pm.put(“khnf”, khnf);

pm.put(“nf”,nf);

if(“1”.equals(jd)){

pm.put(“ks”,”1″);

pm.put(“js”,”3″);

}

if(“2”.equals(jd)){

pm.put(“ks”,”4″);

pm.put(“js”,”6″);

}

if(“3”.equals(jd)){

pm.put(“ks”,”7″);

pm.put(“js”,”9″);

}

if(“4”.equals(jd)){

pm.put(“ks”,”10″);

pm.put(“js”,”12″);

}

return SUCCESS;

}