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

Create your own callback in Java

Creating callback in Java need utilize the interface unlike the javascript there is quite a work to creating callback pattern in Java. using interface public interface WordIntf{ public void saysSomething(String salutation); } Create the... Continue →