permaculture playing cards
The moose likes Java in General and the fly likes Formating Date objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Formating Date objects" Watch "Formating Date objects" New topic

Formating Date objects

Dave Kinkead

Joined: Feb 22, 2003
Posts: 13
I am trying to time stamp an object when sending it to a MS Access database but am struggling to format the date object correctly. When the date component of my statement is removed, the excecuteStatement() method works just fine so Im sure it is the date format.
How do I format it correctly to MS Access format so I don't get anymore 30 line SQLExceptions!?!
Thanks in advance
Greg Charles

Joined: Oct 01, 2001
Posts: 2967

You could probably work it out with a SimpleDateFormat and knowing what format Access likes. However, I suggest using a PreparedStatement, and then using the setDate() method. That way the driver would just figure it out for you.
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1141

Does this help you? It inserts a row into a database table (named "Table1") that has two columns:
  • name with datatype Text
  • updated with datatype Date/Time

  • The below code was tested on Windows XP with Micro$oft Access and J2SE SDK 1.4.1_02

    Of-course, if the above is totally useless to you then
  • Please excuse me.
  • Provide some more details so I can (hopefully) give you something useful instead

  • Good Luck,
    I agree. Here's the link:
    subject: Formating Date objects
    It's not a secret anymore!