Forums Register Login

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

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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).]
That's my roommate. He's kinda weird, but he always pays his half of the rent. And he gave me this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1429 times.
Similar Threads
setFirstDayOfWeek in Calendar
Changing values of contants
Date
week days
how to get day of week from a date
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:02:17.