I’m working with Spring 3.0.2 using Hibernate 3.2.1 and Oracle 10g as a back end. In an Oracle database table, there is a field whose data type is Date. This Date type field is mapped with java.util.Date in Hibernate (POJO) something like the following.
private Date discountStartDate;
While inserting or updating data into the Oracle table, I’m supplying a java.lang.String type date something like this 08/15/2012 15:08:13. There is no problem at all. Everything works well but since Oracle date data type (as far my knowledge) is always mapped with java.util.Date with Hibernate entity, I can’t use other Java APIs like Calendar and I have to use the deprecated constructor of the Date class to deal with Hibernate as follows.
Discount obj=new Discount();
date=new Date(request.getParameter("txtDiscountStartDate"));
obj.setDiscountStartDate(date);
Such deprecated functionality should be avoided. Is there a way to get around this deprecated Date(“StringDate”) constructor in Hibernate?
No, that’s wrong.
You should be parsing that
Stringinto aDateusingDateFormatandSimpleDateFormat.Here is an example.
Here’s another, since this seems difficult for you: