wood burning stoves 2.0*
The moose likes Java in General and the fly likes How to get weeks for a particular year with Calendar object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to get weeks for a particular year with Calendar object" Watch "How to get weeks for a particular year with Calendar object" New topic
Author

How to get weeks for a particular year with Calendar object

Bhakti Sancheti
Greenhorn

Joined: Jun 28, 2011
Posts: 2
How to get weeks for a particular year with Calendar object? What I want is, starting from the first week of a particular year till the end, I need the start date of all the weeks considering Sunday as the first day. For eg. For year 2011 starting from month of January I need all the start dates of every week. 2 Jan 2011- 8 Jan -2011, 9 Jan 2011- 15 Jan 2011 etc.....

Kindly let me know if you have any solution to this...
Sridhar Santhanakrishnan
Ranch Hand

Joined: Mar 20, 2007
Posts: 317


would set the calendar to the Sunday of the week in question. Probably you can then add 7 to the calendar to get the rest of the sundays.

And Welcome to Javaranch.
Bhakti Sancheti
Greenhorn

Joined: Jun 28, 2011
Posts: 2
Thanks Sridhar.

But what I need is maybe an array of Dates/Objects that hold the values of all weeks for a particular year.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 557
Using Sridhar's suggestion and Calendar's add() method you can generate the calendar objects you need and store them in the collection of your choice. Try coding it and come back if you need help.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get weeks for a particular year with Calendar object
 
Similar Threads
Java Calendar vs Java.util.Date
daysOfWeek function implementation
Number of days between the 2 given dates.
week days
How to get end week date from given start date??