AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calendar.DST_OFFSET field being cleared unexpectedly

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.tech
View previous topic :: View next topic  
Author Message
Jim Garrison
Guest





PostPosted: Thu Jun 07, 2007 11:20 pm    Post subject: Calendar.DST_OFFSET field being cleared unexpectedly Reply with quote



Given the following class:

public class TestDate
{
public static void main(String[] args)
{
GregorianCalendar c = new GregorianCalendar();
System.out.println(c.get(Calendar.DST_OFFSET));
c.set(Calendar.YEAR,2006);
System.out.println(c.get(Calendar.DST_OFFSET));
c.set(2006, Calendar.DECEMBER, 31);
System.out.println(c.get(Calendar.DST_OFFSET));
}
}

Can someone explain why the output (when run in the CDT
timezone) is:

3600000
3600000
0

It appears that the set(int,int,int) call clears the DST_OFFSET field,
even though the API explicitly states:

public final void set(int year,
int month,
int date)

Sets the values for the calendar fields YEAR, MONTH, and
DAY_OF_MONTH. Previous values of other calendar fields are retained.
If this is not desired, call clear() first.

What am I missing?

BTW, this is with Sun JDK 1.5.0_10.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> comp.lang.java.tech All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.