Dont format the date by hand!!!
Use a PreparedStatement to write to the database, it handles the formatting
for you.
e.g.:
long curTime = new java.util.Date().getTime();
Connection connection= ... ;
PreparedStatement pstmt = connection.prepareStatement(
V.T.R.Ravi Kumar
Engineer,CCX,BHEL, Haridwar
Phone : Office-91-0133-485260
Res -91-0133-426121
-
- Original Message -----
From: "hugo" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 18, 2002 9
October 18, 2002 6:23 AM
Subject: obtaining date and time in suitable format for MySQL
> Hi
>
> I am javing a jsp file where I would like to get the current date and
> time to be inserted in fields of an SQL table. The date should go into
> the MySQL date field and hence should be of format
Hi
I am javing a jsp file where I would like to get the current date and
time to be inserted in fields of an SQL table. The date should go into
the MySQL date field and hence should be of format -mm-dd. I tried
to use java.sql.Date, but I couldn't get it to work. If I simply use
long date = 0