try{
DateFormat dateFormat;
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
String s1="2009-04-01";
String s2="2009-04-10";
Date startDate = dateFormat.parse(s1);//util类型
Date endDate = dateFormat.parse(s2);
//把年月日日期字符串转换成Date格式的方法是用SimpleDateFormat,但是默认有时分秒.
Criteria c=s.createCriteria(UserBusiness.class);
c.add(Expression.between("month", startDate, endDate));
//这几天关键就在想怎么传入这个Date
result=c.list();
Iterator it=result.iterator();
while(it.hasNext()){
UserBusiness us=(UserBusiness)it.next();
System.out.println(us.getUserid());
System.out.println(us.getBusinessId());
System.out.println(us.getMonth());
}
}catch(HibernateException e){
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}
DateFormat dateFormat;
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
String s1="2009-04-01";
String s2="2009-04-10";
Date startDate = dateFormat.parse(s1);//util类型
Date endDate = dateFormat.parse(s2);
//把年月日日期字符串转换成Date格式的方法是用SimpleDateFormat,但是默认有时分秒.
Criteria c=s.createCriteria(UserBusiness.class);
c.add(Expression.between("month", startDate, endDate));
//这几天关键就在想怎么传入这个Date
result=c.list();
Iterator it=result.iterator();
while(it.hasNext()){
UserBusiness us=(UserBusiness)it.next();
System.out.println(us.getUserid());
System.out.println(us.getBusinessId());
System.out.println(us.getMonth());
}
}catch(HibernateException e){
e.printStackTrace();
}
catch(Exception e){
e.printStackTrace();
}