I am trying to figure out how to get the date which is exactly one year short of the current date and HQL with a parameter
I tried to use the calendar, but I lost it in converting it to the correct format required for Oracle.
calendar cal = Calendar.getInstance (); Cal.setTime (new date ()); Cal.set (calendar.HOUR_OF_DAY, 0); Cal.set (Calendar minutes, 0); Cal.set (calendar. SECOND, 0); Cal.set (Calendar. MILLISECOND, 0); Cal.add (Calendar: IEER, -1); String date lilit = cal.getTime (). ToString (); Date Dates Format = New SimpleDormat ("DD-MMM-Yyyy") Pars (date limit); // This one shows that I try to capture either in throws or throws it in order to wrap it. // date cutoffdate = date format Pars (date limit); // Try this to get any benefit from the query builder. Append ("and c.dateOfContact> =: cutOffDate"); Parameters.put ("cutOffDate", dateFormatter); Alternatively, is there a hibernate-built function for date manipulation? I want all queries to pass a date, which is one year less than the current date.
The Oracle date format is DD-MMM-yyy (ex: 21-June-2013)
I think this will work:
parameters.put ("cutOffDate", cal.getTime ()); If c.dateOfContact is there, java.util.Date or java.sql.Date has to work with cal.getTime ().
No comments:
Post a Comment