This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Number of weeks in a month Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Number of weeks in a month" Watch "Number of weeks in a month" New topic
Author

Number of weeks in a month

Paul Michael Serrano
Ranch Hand

Joined: Nov 22, 2004
Posts: 59
Good Day,

Is there a class in Java that could compute for the number of weeks in a specific month?

Paul
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Calendar.getActualMaximum(Calendar.WEEK_OF_MONTH).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18708
    
    8

And if you don't like the assumptions (about what constitutes a week) built into the Calendar class, you would still use the Calendar class to do the calculations based on your actual requirements.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

You can tweak the week-definition, with two methods: setFirstDayOfWeek and setMinimalDaysInFirstWeek.
Paul Michael Serrano
Ranch Hand

Joined: Nov 22, 2004
Posts: 59
Thanks guys....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number of weeks in a month