mercredi 30 avril 2014

Where am I going wrong while matching the time?


Vote count:

0




How can I match time with what is in the database to the current time ?


This is how I have been doing till now but haven't succeeded. There is a column named stime in the table that has the datatype TIME. It has values in HH:mm:ss



String time = dateFormat.format(new java.sql.Time(new GregorianCalendar().getTimeInMillis()));
int timeattr[] = new int[2];
int i = 0;
for(String a : time.split(":")) {
timeattr[i] = Integer.parseInt(a);
i++;
}
GregorianCalendar gc = new GregorianCalendar(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), timeattr[0], timeattr[1], 0);

// QUERY
String hql = "from Scheduled where stime <= :now";

List list = session.createQuery(hql).setTime("now", new java.sql.Time(gc.getTimeInMillis())).list();
Iterator iterator = list.iterator();

while(iterator.hasNext()) { // never enters the loop }


asked 23 secs ago






Aucun commentaire:

Enregistrer un commentaire