Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Working with dates

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have any suggestions for working with dates that will be stored in a MySQL database?
For example, I want to create a subscription service and store an expiration date in the database.
Should I create the date in Java and then store it in the database or should I have mySQL create the date for me (if that's possible)?
I suppose I'm going to have to convert the date back to a Java object in order to work with it, right?
Any thoughts?
Thanks,
Drew
 
Peter Straw
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the timestamp data type, I found this at http://www.mysql.com/doc/en/DATETIME.html
The TIMESTAMP column type provides a type that you can use to automatically mark INSERT or UPDATE operations with the current date and time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic