| Author |
java.sql.date to string
|
Patrick Mallahan
Ranch Hand
Joined: Apr 22, 2005
Posts: 69
|
|
|
how would i convert a java.sql.date variable to a string?
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
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 ]
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Patrick Mallahan
Ranch Hand
Joined: Apr 22, 2005
Posts: 69
|
|
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
Joined: May 22, 2003
Posts: 657
|
|
What else is going on in setDate/getDate? Example:
|
 |
Patrick Mallahan
Ranch Hand
Joined: Apr 22, 2005
Posts: 69
|
|
Set start/end date get start/end date
|
 |
Steve Morrow
Ranch Hand
Joined: May 22, 2003
Posts: 657
|
|
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.
|
 |
 |
|
|
subject: java.sql.date to string
|
|
|