String year = request.getParameter("year");
String lable = request.getParameter("lable");
String value = request.getParameter("value");
Calendar sc = Calendar.getInstance();//查询的开始时间
Calendar ec = Calendar.getInstance();//查询的结速时间
/**
* 设置年
*/
sc.set(Calendar.YEAR,Integer.parseInt(year));
ec.set(Calendar.YEAR,Integer.parseInt(year));
/**
* 设置月
*/
if(lable.equals("month"))
{
sc.set(Calendar.MONTH, Integer.parseInt(value)-1); //设置月
ec.set(Calendar.MONTH, Integer.parseInt(value)-1); //设置月
}else if(lable.equals("season"))
{
int sea=Integer.parseInt(value)*3;
sc.set(Calendar.MONTH, sea-3);
ec.set(Calendar.MONTH, sea-1);
}else if(lable.equals("inyear"))
{
int sea=Integer.parseInt(value)*6;
sc.set(Calendar.MONTH, sea-6);
ec.set(Calendar.MONTH, sea-1);
}
/**
* 设置天,时,分,秒
*/
sc.set(Calendar.DATE, 1);
sc.set(Calendar.HOUR_OF_DAY,00);
sc.set(Calendar.MINUTE,00);
sc.set(Calendar.SECOND,00);
ec.set(Calendar.DATE, ec.getActualMaximum(Calendar.DAY_OF_MONTH));//取得所选择月的最后一天
ec.set(Calendar.HOUR_OF_DAY,23);
ec.set(Calendar.MINUTE,59);
ec.set(Calendar.SECOND,59);
季度/月查询询中拼开始时间和结束时间
最新推荐文章于 2023-02-13 16:35:56 发布