Results 1 to 2 of 2
Thread: Date as String to TimeStamp
- 08-01-2007, 12:44 PM #1
Member
- Join Date
- Aug 2007
- Posts
- 1
- Rep Power
- 0
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.
- 08-01-2007, 01:43 PM #2
Member
- Join Date
- Jul 2007
- Location
- England, Bath
- Posts
- 47
- Rep Power
- 0
change the first mm to MM as mm represents minutes not Month which is represented by MM
:)
Similar Threads
-
Difference between current date and anothe date
By vijay balusamy in forum New To JavaReplies: 1Last Post: 04-16-2008, 04:15 PM -
Timestamp in SQL format
By Java Tip in forum Java TipReplies: 0Last Post: 02-10-2008, 11:37 AM -
Converting Epoch to string Date
By amyedwards in forum New To JavaReplies: 3Last Post: 12-14-2007, 10:33 PM -
Using java.util.Scanner to search for a String in a String
By Java Tip in forum Java TipReplies: 0Last Post: 11-20-2007, 04:59 PM -
String to Date conversion
By javaplus in forum New To JavaReplies: 2Last Post: 11-06-2007, 07:16 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks