With EJB3 (and jpa, etc) dates can be a little confusing. If you need just the date (no time), use @Temporal(TemporalType.DATE) and you will only get thet date. The time will be zeroed out.
If you want the date with the time, use @TemporalType(TemporalType.TIMESTAMP) and you will get both the date and time.
In both cases, still use java.util.Date or java.util.Calendar (I use java.util.Date). With the eclipse ide, when reverse engineering tables to entities, by default it will plug in java.util.Date with the TemporalType.DATE and you lose the time.
Anyway, hope this helps!
4 comments:
This was very helpful for me. Thanks for posting.
great post :) you saved my time thanks a lot !
Thanks man, you helped me so much
Suppose my client is in India and the ejb is in Germany. Client is passing only the date. The server has to store it in DB. Will temporal solve the time difference problem between India and Germany?
Post a Comment