I am reading data from excel file and updating the sql table. When I read all the contents from excel file are in String format. How do I change the string into Date.
For ex:
String s ='3/31/2003'
When I tried Date renew = new Date(s); it is not storing the correct date.
Cut your String s into month, day and year and use the GregorianCalendar(int year, int month, int dayOfMonth) Constructor to create a GregorianCalendar object... Later get a date instance from it and then do things with DB...
Hope it helps...
Co-author of SCMAD Exam Guide, Author of JMADPlus SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
GregorianCalendar is nice EXCEPT that you have to be very careful with getting Dates & Timestamps you can lose some hours (this can affect Dates too). I second the DateFormat classes.
What are you saying? I thought you said that Santa gave you that. And this tiny ad: