通过时间去筛选查询出来的信息
错误信息
public List GetStaPaperListAllByYearsUnite(Date year ,Date year1,String sunite)
{
StaPaperDAO up=new StaPaperDAO();
List l=null;
l=up.findByHQL(" from StaPaper as b where b.staauditing=1 and( b.staPtime between '+year+' and '+year1+') and b.units.ucoding like '%"+sunite+"%' order by b.staPid desc");
return l;
}
public List GetStaPaperListAllByYearsUnitePage(Date year ,Date year1, String sunite,int pageSize, int iCurrentPage)
{
StaPaperDAO up=new StaPaperDAO();
List l=null;
l=up.findByHQLPage(" from StaPaper as b where b.staauditing=1 and (b.staPtime between '+year+' and '+year1+') and b.units.ucoding like '%"+sunite+"%' order by b.staPid desc",pageSize,iCurrentPage);
return l;
}
if(request.getParameter("ICK")!=null &&request.getParameter("txtUunits")!=null )
{
strUnite=request.getParameter("txtUunits").toString().trim();
strYear=request.getParameter("txtyear").toString().trim();
strYear1=request.getParameter("txtyear1").toString().trim();
url="&ICK=1&txtUunits="+request.getParameter("txtUunits")+"&txtyear="+request.getParameter("txtyear")+"&txtyear1="+request.getParameter("txtyear");
}
int PageSize=10;
int Page=1;
int totalPage=1;
int totalrecord=0;
totalrecord=bll.GetStaPaperListAll().size();
if(!strUnite.equals("0"))
{
totalrecord=bll.GetStaPaperListAllByYearsUnite(Date.valueOf(strYear),Date.valueOf(strYear1),strUnite).size();
}
if(totalrecord % PageSize==0)
totalPage=totalrecord/PageSize;
else
totalPage=(int)Math.floor(totalrecord/PageSize)+1;
if(totalPage==0) totalPage=1;
if(request.getParameter("Page")==null || request.getParameter("Page").equals(""))
Page=1;
else
try
{
Page=Integer.parseInt(request.getParameter("Page"));
}
catch(java.lang.NumberFormatException e)
{
Page=1;
}
if(Page<1) Page=1;
if(Page>totalPage) Page=totalPage;
List<StaPaper> myList=bll.GetStaPaperListAllByPage(PageSize,Page);
if(!strUnite.equals("0"))
{
myList=bll.GetStaPaperListAllByYearsUnitePage(Date.valueOf(strYear),Date.valueOf(strYear1),strUnite,PageSize,Page) ;
}
这个问题怎么样解决?
现在变量类型是Date
用Timestamp 也不行
hibernate里面映射是Date ,
sql 2005 数据库表里面的staPtime类型是datetime
所以对于的时间是2010-12-11 00:00:00:0 页面文本框的取值是2010-12-11

