Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.sql.date to string  RSS feed

 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how would i convert a java.sql.date variable to a string?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend the toString() method of java.sql.Date class.

If you need to control the formatting, look at java.text.DateFormat and java.text.SimpleDateFormat.
[ July 11, 2005: Message edited by: Paul Sturrock ]
 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i used .toString() and it didnt seem to work. I am passing a string of the date formatted like yyyy-mm-dd to a class that converts the string to a java.sql.Date variable here is the snippet:



Then I call getStarDate which consists of nothing but a return on the internal private variable and I am not getting anything in the return. It is coming abck null
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What else is going on in setDate/getDate?

Example:
 
Patrick Mallahan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set start/end date


get start/end date
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There must be some other code that is interfering. Refer to the example I posted. If you still run into the problem, please post a short, concise, executable example of what you're trying to do. This does not have to be the actual code you are using. Write a small example that demonstrates your intent, and only that. Wrap the code in a class and give it a main method that runs it - if we can just copy and paste the code into a text file, compile it and run it without any changes, then we can be sure that we haven't made incorrect assumptions about how you are using it.

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!