Problem with system time in java
Hi all,
I'm trying to use the following code to get the current system time:
SimpleDateFormat sdf =new SimpleDateFormat("yyyyMMddHHmm");
sdf.setTimeZone(new SimpleTimeZone(0,"GMT"));
qty.setLastmod(sdf.format(new Date()));
System.out.println("LAST MODIFIED DATE:"+qty.getLastmod());
[
But when the system time is 12:26 am. It returns it as 0526. The full format is 200701080526 for yyyyMMDDhhmm when it should be 200701080026. Can anyone please help whats wrong?
Thanks in advance!!!
[716 byte] By [
j_raya] at [2007-11-26 14:29:10]

> Yes, I'm using GMT timezone.
"using" and "in" are two different things. What is your OS clock set to be in? The hour and minute 0526 is exactly what would be returned at 12:26am if said executing computer was in the eastern standard time zone. ( OS clock instructed that it is in EST )
Let's ask that question in a different way:Are you in England?Or Ireland, I guess. Maybe Iceland, or the west coast of France? I haven't memorized time zone maps.Message was edited by: paulcw
Or perhaps: what does this code output?
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");
sdf.setTimeZone(new SimpleTimeZone(0, "GMT"));
Date d = new Date();
String s = sdf.format(d);
System.out.println(d);
System.out.println(s);
Sorry if I didnt answer your question right. You are correct. I'm in the EST so it is subtracting 5 from GMT.
But my actual problem is different. At midnight 12am/after 23:59, the system shows the time as 24:00 instead of 00:00. And from here keeps on adding 24:01,24:02,24:03,........etc until 1:00am. How do I correct this to 00:00.
Thanks for your help!