1

I've learn to map usually the date fields in a DB to a java.util.Date field in a Java Bean. However, is this approach still useful? I know that Date are still in java mainly for backwards compatibility, and that Joda time tends to perform better than java.util.Calendar, but I'm not sure how well it goes with Hibernate.

So, my questions are the following:

  • In hibernate, which are the recomended data type for a Date field in a DB? Date, Calendar, Joda Time, or any other?
  • It is still true when I don't care about the TimeZone or the Time portion? For example, when I only want to store the date
  • What about pure Java beans? Can I still implement the recommendations that are true for Hibernate mappings?

Thanks in advance

McSonk
  • 493
  • 1
  • 4
  • 11
  • 2
    If you only want to store the date, then the appropriate Java class is `java.time.LocalDate`. See [this answer](https://stackoverflow.com/a/44715566) for how to get Hibernate to use that class. – Dawood ibn Kareem Nov 17 '17 at 19:55

0 Answers0