[Advanced-java] Bug in the SimpleDateFormat

NORELL, Peter Peter.NORELL at london.sema.slb.com
Mon Mar 24 11:28:25 2003


Hi,

It looks correctly to me. I would presume your default locale has daylight
saving time occuring 30th of March.
By default that means that there is no 02.01 as the clock will be set
forward to 03.00 at the strike of 02.00. There is no 02.45 existing on 30th
of March for my locale. If you set your date format to not be lenient I
would presume you get a fun little exception (can not verify since no java
compiler is close at hand) when parsing the date.

Applying this logic to the real world, if I set my alarm clock to 02.45 the
evening 29th March, two things could happen:
1) It rings at 03.45 (altough the clock shows 02.45 still)
2) I wake up at 02.00 and sets it forward 1 hour and it will not ring at all

Non-java ponderings (not to be answered on the list):

I've always been curious on how this particular scheme works out for
business that has people employed 24 hours. Does this hour just dissapear?
Does the individual work an hour shorter/longer depending on the change?
Does it affect budget or salaries? If so, can company profit on the interest
it gets on this money until winter-time arrives?

Best regards,
Peter Norell

-----Original Message-----
From: phoenix@vt4.net [mailto:phoenix@vt4.net]
Sent: 24 March 2003 11:15
To: advanced-java@lists.xcf.berkeley.edu
Subject: [Advanced-java] Bug in the SimpleDateFormat



Hello everybody 
I have discovered a small bug in 
the DateFormat-class

I use the SimpleDateFormat-class to parse a String ("30-03-2003 02:45") to a
Date with format ("dd-MM-yyyy HH:mm")
 
These leads to the following code :
java.text.SimpleDateFormat dateFormat = new
java.text.SimpleDateFormat(("dd-MM-yyyy HH:mm");
String dateStr = "30-03-2003 02:45";
java.util.Date date = dateFormat.parse(dateStr);
 
The date contains the value Sun Mar 30 03:45:00 CEST 2003
so +1 uur, this happens only for the dates from  30-03-2003 02:00 till
30-03-2003 02:59.
The other dates do come out right.
 
Can anybody help me ?
 
Bart Laeremans


---------------------------------------------------------------------
Gratis internet toegang en jouw @vt4.net adres op http://www.vt4.net



_______________________________________________
Advanced-java mailing list
Advanced-java@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java


_________________________________________________________
This email is confidential and intended solely for the use of the 
individual to whom it is addressed. Any views or opinions presented are 
solely those of the author and do not necessarily represent those of 
SchlumbergerSema.
If you are not the intended recipient, be advised that you have received
this email in error and that any use, dissemination, forwarding, printing, 
or copying of this email is strictly prohibited.

If you have received this email in error please notify the
SchlumbergerSema Helpdesk by telephone on +44 (0) 121 627 5600.
_________________________________________________________