Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Number of weeks in a month

 
Paul Michael Serrano
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Day,

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

Paul
 
Rob Spoor
Sheriff
Pie
Posts: 20529
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calendar.getActualMaximum(Calendar.WEEK_OF_MONTH).
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20529
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can tweak the week-definition, with two methods: setFirstDayOfWeek and setMinimalDaysInFirstWeek.
 
Paul Michael Serrano
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic