Java date processing

Posted by Don on Stack Overflow See other posts from Stack Overflow or by Don
Published on 2010-05-21T15:27:07Z Indexed on 2010/05/21 15:30 UTC
Read the original article Hit count: 171

Filed under:
|
|

Hi,

Given an instance of java.util.Date which is a Sunday. If there are 4 Sundays in the month in question, I need to figure out whether the chosen date is

  • 1st Sunday of month
  • 2nd Sunday of month
  • 2nd last Sunday of month
  • Last Sunday of month

If there are 5 Sundays in the month in question, then I need to figure out whether the chosen date is

  • 1st Sunday of month
  • 2nd Sunday of month
  • 3rd Sunday of month
  • 2nd last Sunday of month
  • Last Sunday of month

I've had a look in JodaTime, but haven't found the relevant functionality there yet. The project is actually a Groovy project, so I could use either Java or Groovy to solve this.

Thanks, Donal

© Stack Overflow or respective owner

Related posts about java

Related posts about groovy