• Post Reply Bookmark Topic Watch Topic
  • New Topic

String to SQL date format conversion  RSS feed

 
suresh dhanapal
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to convert string numeral to sql date format, I am not getting expected format. Below is the sample code and result.
Can some one help me how to achieve sql date format to insert in to table.



Output:
dob:Thu Jul 26 00:00:00 EST 199
0199-07-26

 
Paul Clapham
Sheriff
Posts: 22838
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to do that conversion so you can put the date into a database table, why are you concerned about how Java displays it as a string? That's irrelevant. All you need to do is to put your java.sql.Date object into your PreparedStatement using its setDate() method.
 
suresh dhanapal
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
I am doing the same, thing here is I need to convert the string to date before setting in to sql date
how do we pass this to


 
Paul Clapham
Sheriff
Posts: 22838
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You bring back your code from the original post. (I assume it's okay, you didn't format it with the code tags so it's a bit hard to read and therefore I didn't look at it too closely.) And then you do this:

 
suresh dhanapal
Ranch Hand
Posts: 40
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all set,Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!