This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi All, How can i get the number of weeks in a year? Usually there are 52 weeks in a year but for example in 2006 there are 53 weeks. Is there any way to check it? I have to change this code because 52 is hardcoded:
Thanks in advance [ January 28, 2007: Message edited by: Kudret Serin ]
will always return 53, the maximum possible value for any year. However
will return 52 or 53, the maximum for the *current* year (whatever c has been set to). This is probably what is desired here, but it depends on how you want to count weeks. It may be useful to call
if you want each week to start on a Monday (if you don't like assuming your locale's default is valid).
I recommend testing the results carefully, and if you don't agree with them, tell us specific examples where you think the result should be different. There are several subtly different ways that one might count weeks. [ January 28, 2007: Message edited by: Jim Yingst ]