• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Formating Date objects

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic