简体   繁体   中英

Java, hibernate, h2db and mysql date and time variable

I'am on decision: "Which format/type of variable I should use to store/work on/convert/ dates in my Java/Spring or PlayFramework app.

The most common date format use in my app will be: YYYY-MM-DD hh:mm:ss. fe 2014-07-17 15:06:00

Example usage of date is: creation datetime, update datetime, last visited datetime The date will be store in database using hibernate or native sql query.

I will be working on date objects (fe adding dayes, months, sec or houres)

Please give me some advice, what should I use in Your opinion (maybe some good article)

I am thinking about:

  • unix timestamp as long or int variable
  • java.util.date object
  • java.sql.timestamp object
  • java.util.calendar object

Decide to use Joda Time. The best java date and time library!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM