Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Formatting Date Object

 
Adewale Adebusoye
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to format an object of java.util.Date into the dd/mm/yy format. Im using it for a database program in which the date is implicitly inserted into a table when a function is called, and ive been trying to get the date in dd/mm/yy format.
Any ideas?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're trying to format the date into a String (in whatever format) so that you can insert it into a database table, in a column that is declared as DATE, then the best idea is to not do that. Use a PreparedStatement:However if it's a text column (which also sounds like not such a good idea) or if you just need the date formatted so you can display it, then use a java.text.SimpleDateFormat object to do that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic