aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Formating Date objects" Watch "Formating Date objects" New topic
Author

Formating Date objects

Dave Kinkead
Greenhorn

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
Dave
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

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: 1121

Dave,
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,
    Avi.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Formating Date objects
     
    Similar Threads
    Parsing a date and retaining the format
    Date,Calendar?help!!!!
    Insert a row into MS Access2003 successfully,But the long date(YYYY/MM/DD HH:mm:ss) was changed
    Date Format
    Date format