aspose file tools
The moose likes Java in General and the fly likes return date for a given week number in a month Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "return date for a given week number in a month" Watch "return date for a given week number in a month" New topic
Author

return date for a given week number in a month

Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 264
Hi,

Can someone urgently post a snippet code that will return the date if the week number and the weekday (like wednesday) for a given month in an year is passed.

ex: If I say 2nd wednesday of August in 2004 , it must return the date for second wednesday. URGENT
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Simple. Use a Calendar. Set the YEAR to 2004, MONTH to AUGUST, the DAY_OF_WEEK_IN_MONTH to 2, and the DAY_OF_WEEK to WEDNESDAY. Get the time, done.

If this confuses you, you might want to study the differences between WEEK_OF_MONTH and DAY_OF_WEEK_IN_MONTH.

- Peter
[ August 23, 2004: Message edited by: Peter den Haan ]
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
More detail of Calendar

day, month and year are start with ZERO (0) so

day : 0 - 30 (1-31)
month : 0-11 (1-12)
year : 2003 (2004)


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Despite the bugs that might occur, I just developed a small application to clearly see what we have here... Hope this helps...



Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: return date for a given week number in a month
 
Similar Threads
Get WeekStart Date & End date by Week Number in java
Help Needed
How to get end week date from given start date??
confusing output of a date
daysOfWeek function implementation