Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i get the first and the last date for a specific week

 
Rinku Sharma
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi freinds,
i am making a calendar application and i am stuck with the weekly calendar module.Please tell me how do i get the first date and the last date for a perticular week.
bye,
amit
 
S Chandra Mohan
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better u store a particular date as the root date.
And start calculating from that date as fixed.
Also take into consideration the LEAP years and others.
If u want more put ur reply here.
All the best
 
Akanimo Udoh
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rinku,
I don't really think you'd want to attempt to rewrite the whole java date/calendar libraries! The easiest thing for you to do would be to use the java.util.Calendar (get an instance by calling the static Calendar.getInstance() method).
Calendar has a function Calendar.get(int) which can be used to get the day of week ( mon,tues,...) by using as getInstance(DAY_OF_WEEK). This factors in leap years etc so you don't have to worry about that. It would be very easy to write a function that accepts any date and produces the first and last day of that week by subtracting/adding the appropriate number of days based on the "day of week" obtained using the function above.
Akanimo.

[This message has been edited by Akanimo Udoh (edited July 10, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic