persisting object of perticular date format
Hi,
I have a date in string format that is coming from front end.
format yyyy-MM-dd'T'HH:mm:ss.
e.g 2010-12-25T12:00:00
I created entites from the tables . Here is my employee entity.
Class Emp{
String id,
java.sql.date joinDate
}
The joinDate datatype of emp table in database is Date.
As i see to_date() is not applicable in JPA, How can i persist the joined date in the same format 2010-12-25T12:00:00 into the database by using jpa.
How can i specify this format yyyy-MM-dd'T'HH:mm:ss before inserting the values into the database.
like
emp.setDate();
em.persist(emp);
Later on i want to search the emp who has joined in the format (yyyy-mm-dd) 2010-12-25, so that i can get all the values from the database
2010-12-25T12:00:00
2010-12-25T11:00:00
2010-12-25T10:05:00
@NamedQuery(name="getEmployeeByDate",query="select p from Emp p where p.joinDate =? ")
Thanks