Connecting Tech Pros Worldwide Help | Site Map

Calendar class question

  #1  
Old July 17th, 2007, 06:35 AM
Z.K
Guest
 
Posts: n/a
I was wondering if someone could explain something that while not a big
deal, I would not mind understanding why. When I set the Month field
with the set command with the value 1 and then use get to read it back,
it reads it as 0 and not 1.

Z.K.
  #2  
Old July 17th, 2007, 07:15 PM
John W. Kennedy
Guest
 
Posts: n/a

re: Calendar class question


Z.K wrote:
Quote:
I was wondering if someone could explain something that while not a big
deal, I would not mind understanding why. When I set the Month field
with the set command with the value 1 and then use get to read it back,
it reads it as 0 and not 1.
This should not be. Please provide a complete example of what you are doing.

--
John W. Kennedy
"The first effect of not believing in God is to believe in anything...."
-- Emile Cammaerts, "The Laughing Prophet"
  #3  
Old July 20th, 2007, 05:15 AM
Z.K
Guest
 
Posts: n/a

re: Calendar class question


John W. Kennedy wrote:
Quote:
Z.K wrote:
Quote:
>I was wondering if someone could explain something that while not a
>big deal, I would not mind understanding why. When I set the Month
>field with the set command with the value 1 and then use get to read
>it back, it reads it as 0 and not 1.
>
This should not be. Please provide a complete example of what you are
doing.
>
This is the code. I enter a 2 for month and I get 1 using the get command.

Z.K.

-------------

GregorianCalendar d = new GregorianCalendar();

d.set(Calendar.DAY_OF_MONTH,1);
d.set(Calendar.MONTH,2);
d.set(Calendar.YEAR,2004);
d.set(Calendar.DAY_OF_YEAR,32);

System.out.printf("%d-%d-%d\nDayOfYear =
%d\n",d.get(Calendar.MONTH),d.get(Calendar.DAY_OF_ MONTH),d.get(Calendar.YEAR),d.get(Calendar.DAY_OF_ YEAR));
  #4  
Old July 23rd, 2007, 08:55 AM
Robert Larsen
Guest
 
Posts: n/a

re: Calendar class question


Z.K wrote:
Quote:
GregorianCalendar d = new GregorianCalendar();
>
d.set(Calendar.DAY_OF_MONTH,1);
d.set(Calendar.MONTH,2);
d.set(Calendar.YEAR,2004);
d.set(Calendar.DAY_OF_YEAR,32);
>
Last I checked day 32 of the year was in february so Java does nothing
wrong.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
implementing a calendar class python101 answers 16 November 15th, 2007 02:50 PM
object/class question Jim answers 2 November 24th, 2005 07:15 PM
Custom Calendar webcontrol Peter answers 1 November 19th, 2005 10:52 PM
How: Hyperlink in calendar VB Programmer answers 1 November 18th, 2005 05:15 PM