Transaction tran = getSession().beginTransaction(); List l = null ; Date da2 = new Date(System.currentTimeMillis()); System.out.println("现在的时间是====="+(da2)); Calendar cal = Calendar.getInstance(); cal.setTime(da2); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date begin = cal.getTime(); cal.add(Calendar.DATE, 1); Date end = cal.getTime(); String hql = "from InventoryN in where in.ended <:end"; System.out.println("11111111111111111111"); Query q = getSession().createQuery(hql); System.out.println("222222222222222"); q.setTimestamp("end", end); System.out.println("3333333333333333333"); l = q.list() ; tran.commit(); return l ;
这是我对时间的过滤产生一个时间字符串,格式:yyyy-MM-dd Oralce数据库hql = " from InventoryN in where to_char(in.ended,'yyyy-mm-dd') <:end";
List l = null ;
Date da2 = new Date(System.currentTimeMillis());
System.out.println("现在的时间是====="+(da2));
Calendar cal = Calendar.getInstance();
cal.setTime(da2);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date begin = cal.getTime();
cal.add(Calendar.DATE, 1);
Date end = cal.getTime();
String hql = "from InventoryN in where in.ended <:end";
System.out.println("11111111111111111111");
Query q = getSession().createQuery(hql);
System.out.println("222222222222222");
q.setTimestamp("end", end);
System.out.println("3333333333333333333");
l = q.list() ;
tran.commit();
return l ;
Oralce数据库hql = " from InventoryN in where to_char(in.ended,'yyyy-mm-dd') <:end";