From what I have read, there are 3 types of TemportalTypes you can select when dealing with dates in JPA. They are:
DATE
Map as java.sql.Date
TIME
Map as java.sql.Time
TIMESTAMP
Map as java.sql.Timestamp
I used the TIMESTAMP
and as an example, it persists my dates like so: 2014-10-10 02:12:39
What I have noticed though, is that I am losing AM/PM with my dates. Assume my date came in as the String 2014-10-10 02:12:39 PM
, it would get saved as 2014-10-10 02:12:39
. When I went to access it, it would be AM
instead of PM
since my date format is MMM dd, yyyy HH:mm:ss a
.
Which TemporalType should I use to keep that AM/PM information in the database?