This week's book giveaway is in the
We're giving away four copies of
and have Sam Newman on-line!
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
this week in the
Java in General
String to DATE
Joined: May 14, 2004
Jun 26, 2004 06:28:00
I am reading data from
file and updating the sql table. When I read all the contents from excel file are in
format. How do I change the string into Date.
String s ='3/31/2003'
When I tried Date renew = new Date(s); it is not storing the correct date.
I need to insert 3/31/2003 into the DB table.
Joined: Sep 13, 2002
Jun 26, 2004 20:37:00
Take a look at the api docs for
. It provides the mechanism for converting strings into date objects and vice-versa
Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Ko Ko Naing
Joined: Jun 08, 2002
Jun 28, 2004 01:52:00
The simplest way is...
Cut your String s into month, day and year and use the
(int year, int month, int dayOfMonth) Constructor to create a
object... Later get a date instance from it and then do things with DB...
Hope it helps...
SCMAD Exam Guide
, Author of
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Greg T Robertson
Joined: Nov 18, 2003
Jun 28, 2004 06:06:00
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
Have you checked out
subject: String to DATE
exporting html tables to excel
Reading date from excel file
Import from and export to Excel
Question on Pass By Reference
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015