I have two really tough Calendar class questions that resemble word problems (two variables known, third unknown).
first You have month and year (integer format). How many days were in that month? Example: 10/2005,4/2004,6/2006
second You have week and year (integer format) What month does it refer to? Example: week5,week10,week32,week40 and 2006,2005,2002
I'm not familiar with Calendar classes but it seems you would create a calendar object, set the month and year, generate milliseconds...then I'm stuck.
Any ideas?
Keith Lynn
Ranch Hand
Joined: Feb 07, 2005
Posts: 2341
posted
0
Peter, I would recommend looking at the API docs for the Calendar class.
Peter Wipperfurth
Greenhorn
Joined: Jul 05, 2006
Posts: 4
posted
0
Originally posted by Keith Lynn: I would recommend looking at the API docs for the Calendar class.
Thanks Keith, found a solution on the web for the second problem:
However, the third result (June 2006) has too many days:
max days in month: 6 in year: 2006 month: 6 year: 2006 max days: 31
What modifications are needed to return correctly?
Peter [ July 05, 2006: Message edited by: Peter Wipperfurth ]
Andy T�pfer-Hinz
Greenhorn
Joined: Jul 05, 2006
Posts: 1
posted
0
I think this is correct as the months are counted from 0 to 11, so month 6 is july which has 31 days !
Peter Wipperfurth
Greenhorn
Joined: Jul 05, 2006
Posts: 4
posted
0
so month 6 is july which has 31 days !
Thanks!
Wu Kong
Greenhorn
Joined: Jun 12, 2006
Posts: 5
posted
0
For Gregorian calendar, 1) Find the max. # of days for a particular month - solution is avaliable
2) Find the month, given the week # in a year - not easy. A week may span two months. However, it is possible to find out the 1st day of Week #xx is in which month, for a particular calendar year.
NB: Please check getFirstDayOfWeek() and getMinimalDaysInFirstWeek(). [ July 06, 2006: Message edited by: Wu Kong ]