java.util.Date appears to have been deprecated, and, the weird starting off of months from zero (0) rather than from one (1), is a turn-off in terms of code readability, imho.
It's been suggested to use other libraries, whilst Oracle are planning to release a design as proposed with Java SE 7.
How do you code dates in the meantime? Do you find issues and provide workarounds for dealing with timezone differences, and, DST?
1. Joda.org - open source design for multiple calendar systems that is advertised to be ISO 8601 compliant, available at http://joda-time.sourceforge.net.
2. JSR 310 - JSR 310: Date and Time API - http://jcp.org/en/jsr/detail?id=310 - recommendation to review DateTime structures in Java.
3. java.util.GregorianCalendar class see Java Platform Standard Ed. 6 API - http://download.oracle.com/javase/6/docs/api.
4. Daylight Saving Time (DST) - http://en.wikipedia.org/wiki/Daylight_saving_time.
I've also note the following output:
Fri Apr 15 23:02:34 CEST 2011
Thu Jan 15 00:00:00 CET 3880
What is CEST 2011, and, CET 3880? Is it a bug that 3880 is the output instead of '1980'?
There's no need for "workarounds" if you're dealing with time zones and daylight saving time, either. The java.util.Calendar class (and GregorianCalendar) do a perfectly good job of that. It mentions that in the first paragraph of the Date documentation. Admittedly it's clunky and full of premature optimizations (like numbering months starting from zero) which produced a large crop of subtle bugs, and a 21st-century version is long overdue, but it still does its job perfectly well.
Paul Clapham wrote:Likewise if you have another look for the documentation for the (deprecated) constructor you used there, you'll see where the extra 1900 came from.
Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
I'm still in the dark...
public Date(int year,
Deprecated. As of JDK version 1.1, replaced by Calendar.set(year + 1900, month, date) or GregorianCalendar(year + 1900, month, date).
Allocates a Date object and initializes it so that it represents midnight, local time, at the beginning of the day specified by the year, month, and date arguments.
year - the year minus 1900.
month - the month between 0-11.
date - the day of the month between 1-31.
this is what it says in the documentation, maybe this helps you.
Paul Clapham wrote:I believe "CEST" is "Central European Standard Time" or something like that. Likewise "CET". Based on the information you posted it does appear to me that you are in that time zone.
Yes but I was wondering why one line reads 'CEST' and and another reads 'CET', it's inconsistent, and, looks like witchcraft to me :)
Jon Camilleri wrote:Yes but I was wondering why one line reads 'CEST' and and another reads 'CET', it's inconsistent, and, looks like witchcraft to me :)
There's a logical explanation for that: on 15 April summertime (CEST) is used in Europe, and on 15 January wintertime (CET) is used.