This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get weeks for a particular year with Calendar object

 
Bhakti Sancheti
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic