|
Date as String to TimeStamp
Hi,
I'm trying to convert date & time presented in String to TimeStamp object (so it could be written to DB).
I've created a small program to test this, but the problem is, that every time, when I check the resulting Timestamp object the date part always resets to '01' - it's the same thing when writtne to the DB:
String t2,st = "16/08/2007 09:04:34";
SimpleDateFormat sdf = new SimpleDateFormat("dd/mm/yyyy hh:mm:ss");
Date date = sdf.parse(st);
Timestamp timestamp = new Timestamp(date.getTime());
t2 = timestamp.toString();
// T2 will show: "2007-01-16 09:04:34.0"
anyone knows how to solve this issue ?
thanks.
|