• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

urgent help..Using Calendar instance

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In my application interface,i have a dropdown for selecting an year.
When an year is selected,I have to get all sundays of that year.how can i get it ..any one pls help
thanks.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Now the ArrayList days has Date items for each Sunday of the Year.
 
meera jan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you so much for the given sample.I tried alot with Calendar.but didn't work out.thanx..
one more doubt i have.Is it possible to get all the first saturdays of the year similarly...
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All saturdays are exactly the same, just replace SUNDAY with SATURDAY.
 
Martin Simons
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even better is to put the above into a method and replace Calendar.SUNDAY with a parameter that can be passed into the method along with the year variable.
 
meera jan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you so much for the given sample.I tried alot with Calendar.but didn't work out.thanx..
one more doubt i have.Is it possible to get all the first saturdays of the year similarly...
 
meera jan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes martin,I tried it.If SUNDAY is replaced by SATURDAY ,it will give all the Saturdays.But what i want is only the 1st saturdays,2nd saturdays...and so on.Is it possible with this.
thanx
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want only the first n Saturdays (or which ever day), you could add a parameter, let's call it numDays, and update previous code with:




I think that should get the job done for you.
 
Marshal
Posts: 28303
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by meera jan:
Yes martin,I tried it.If SUNDAY is replaced by SATURDAY ,it will give all the Saturdays.But what i want is only the 1st saturdays,2nd saturdays...and so on.Is it possible with this.
thanx

Well, obviously you would have to write some more code if you wanted to include only the first Saturday of every month. But it's your turn to write some code now. If you don't know what code to write, start by figuring out how to tell if a Saturday is the first Saturday of a month. Get yourself a real calendar (one of the paper ones) if the answer doesn't come to you right away and start looking through it for inspiration.
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see what Meera was asking now.

Meera,
Consider the fact that the 1st Saturday of the month will have a date between ? and ?.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic