Link to home
Start Free TrialLog in
Avatar of sangameshrh
sangameshrh

asked on

Changing date format while inserting to mysql from java

I have this code

Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh-mm-ss");
String dateOut = formatter.format(date);

stament.executeUpdateQuery("INSERT INTO Date_Time_Table(dt_Time) VALUES(' " + dateOut + " ' ) ");

But it is stored as 2007-08-14
the time is not there
and also if I change the format to dd/mm/yyyy it is not accepting the format

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ajay-Singh
Ajay-Singh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin