[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A little problem with Date.getDate()
From: |
Tom Tromey |
Subject: |
Re: A little problem with Date.getDate() |
Date: |
30 Jul 2001 21:22:46 -0600 |
>>>>> "Gansha" == Wu, Gansha <address@hidden> writes:
Gansha> [ from GregorianCalendar.java ]
Gansha> if (weekday <= 0) <- notice here.
Gansha> weekday += 7; <- notice here.
This code is correct. Calendar defines SUNDAY==1.
Gansha> - return cal.get(Calendar.DAY_OF_WEEK);
Gansha> + int day = cal.get(Calendar.DAY_OF_WEEK);
Gansha> + return day == 7?0:day;
I think the correct fix is to use this:
return cal.get(Calendar.DAY_OF_WEEK) - 1;
Date defines the days starting at 0, while Calendar defines them
starting at 1.
I'm going to check this in.
Tom