Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

persisting object of perticular date format

user540571Feb 2 2011 — edited Feb 6 2011
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2011
Added on Feb 2 2011
3 comments
721 views