• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I get the date of a specific weekday with the weeknumber as attribute?

 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I'm currently working on a webapp which is supposed to handle the booking of several conference rooms.
Right now I'm trying to make a class that can get all the days of a specific week, and set their dates.
In the end you should be able to ask for any given week a specific year, and get a list of the seven days and their dates.

The method I'm struggling with looks like this:




Here things go a bit pearshaped. Is there any way that I can get the dates for the weekdays of a specific week?
Let's say that the seven dates in week 5 are 26, 27, 28, 29, 30, 31, 1.
Is there any way for me to get them out so I can call day.setDate(someInt) on each day?
Or do you have any other suggestions for how I could make this work?

Appreciate it!
Regards
Alia
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out java.util.Calendar.
 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did, didn't help me out that much.
Or maybe I just don't get how it works.
I'd really love a method that looked something like this:



But looking through the methods provided in Calendar I can't find anything close to this, and I can't figure out how I could make one myself. Is it possible to make one yourself, you think?
Any tips on how I should use Calendar to make one?
Thanks again.
 
Rob Spoor
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use Calendar.SUNDAY until Calendar.SATURDAY for your weekdays, it's actually quite simple:

For instance, getDate(2009, 5, Calendar.TUESDAY) returns 27 - and in week 5 of 2009, January 27th was a Tuesday.
 
Alia Huss
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow! Thank you!
Now I finally have an idea about how to fix this.

Thank you!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic