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 4 throw rest service to Host

This part actually my experiment to throw rest message to host we will using spring boot as RestFul service and using those service to throw ISOMsg as JSON data upon the request on web. If you read the previous tutorial (Part 3) the code... Continue →