String day = request.getParameter("day"); String month = request.getParameter("month"); String year = request.getParameter("xage"); how do I generate the sql date from these three integers int d = Integer.parseInt(day); int m = Integer.parseInt(month); int y = Integer.parseInt(year);
SCJP, SCJD, SCWCD, SCBCD, SCEA
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
posted
0
The deprecated Date(y, m, d) constructor sure was a lot easier to use if you don't need i18n (internationalisation). - Peter
Dave Soto
Ranch Hand
Joined: Sep 15, 2001
Posts: 55
posted
0
The deprecated Date(y, m, d) constructor sure was a lot easier to use if you don't need i18n (internationalisation). - Peter
I know this post is OLD, but I just needed to say "YOU CAN SAY THAT AGAIN!" I started my JDBC Date Fun trying to use DateFormat, but all of the methods return java.util.Date, not java.sql.Date. To the best of my knowledge (PLEASE correct me if anyone knows better) there is NO way (other than something similar to the above) to simply convert between java.util.Date and java.sql.Date. What a hassle.
Also Ravindra, you can construct a sql Date by - java.sql.Date.valueOf(s) where s = a string in JDBC date escape format, "yyyy-mm-dd"
Dave Soto
Ranch Hand
Joined: Sep 15, 2001
Posts: 55
posted
0
Thanks very much for the getTime() recommendation. That works wonderfully.
bhaskar nagaraja
Greenhorn
Joined: Aug 10, 2001
Posts: 9
posted
0
hello all, Actually i am using calender class and Timestamp class adn storing the date with time in the sql database , but the thing is while retreiving the date , the second part of the time is not displaying , so can u suggest me how to get the date along wiht time along with seconds . Thanks in advance, bhaskar [This message has been edited by bhaskar nagaraja (edited October 16, 2001).]
shilpa kulkarni
Ranch Hand
Joined: Jun 07, 2000
Posts: 87
posted
0
Don't use the resultset.getDate() method when retrieving value, use resultset.getTimestamp()