How to select Query for today date using Java

I have encounter problem to select query from my oracle database using conditional to select record just for current data. After trail and error and searching all around the internet finally I found the solution

Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,0);
calendar.set(Calendar.MINUTE,0);
calendar.set(Calendar.SECOND,0);
Date fromDate = calendar.getTime();

Calendar toCalendar = Calendar.getInstance();
toCalendar.set(Calendar.HOUR_OF_DAY,23);
toCalendar.set(Calendar.MINUTE,59);
toCalendar.set(Calendar.SECOND,59);
Date toDate = toCalendar.getTime();

//Using Hibernate criteria
criteria.add(Restriction.between(datefield,fromDate,toDate));

That’s it.

 
0
Kudos
 
0
Kudos

Now read this

Learn JPOS Part 3 Transaction Manager and Selector

Hi There, in this is the part 3 I will give you the example about JPOS Transaction Manager and Selector. I will start with simple scenario in this example we will have JPOS service to response message that coming from client simulator... Continue →