Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

insert and get date in postgresql

 
hani Ibrahim
Ranch Hand
Posts: 182
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear all,
im so weak with type Date .so i dont know how to make Date in format:
mm/dd//yyyy from java to get Date from PC then insert it in a table with column of type date.
please give me how to make this to insert date in db..and also how to get date from a column then convert it to java style .
please help
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hani,
Take a look at the SimpleDateFormat class. it lets you convert from String to Date and back. Then you can use a PreparedStatement's setDate() method and ResultSet's getDate() method to talk to the database with a date object.
 
Paul Clapham
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, SimpleDateFormat produces a java.util.Date object but JDBC works with java.sql.Date objects. Fortunately it's easy to create a java.sql.Date object from a java.util.Date object, just check its list of constructors.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic