Article View: borland.public.jbuilder.java.language
Article #19703GregorianCalendar & Date?
From: Mike King
Date: Mon, 05 Jan 1998 00:00
Date: Mon, 05 Jan 1998 00:00
31 lines
1765 bytes
1765 bytes
I interpret that the calendar is used to transform a date in
milliseconds to year month, etc and visa versa, but the calendar object
does not behave as I expect!
When the following code is traced via debug, and calendarDay is
inspected, none of the time fields have been set!
Also b shows as false in both cases, varifying that the time fields are
not set. The timezone line is just to check that a default timezone has
been allocated. It has!
Calendar calendarDay = GregorianCalendar.getInstance();
TimeZone tz = calendarDay.getTimeZone();
b = calendarDay.isSet(Calendar.YEAR);
b = calendarDay.isSet(Calendar.WEEK_OF_YEAR);
I notice that Date has a variable GregorianCalendar cal, but that the
only method that updates it is a decremented constructor!
What is the essential basic relationship and behaviour between Date and
Calendar? Should one replace dates by calendars, or should the date
object be the persistent object with calendars coming and going as
needed for transformation?
Should all the time fields be automatically set when a date in
milliseconds is assigned to a calendar object? If not, how does one set
them? If they are not set, how does one use the calendar for extracting
the Year, Month, etc?
Any help will be appreciated,
Mike King
Technical Details
Message-ID:
<34B06A69.5B9ACAE3@icon.co.za>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,16af0d3d9f66a340,start X-Google-Attributes: gidf74b3,public From: Mike King <mcking@icon.co.za> Subject: GregorianCalendar & Date? Date: 1998/01/05 Message-ID: <34B06A69.5B9ACAE3@icon.co.za> X-Deja-AN: 312861613 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Organization: None Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language