• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Calendar problem

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question regarding the use of Calendar.

User will give year (e.g 2006,2007, etc.) as input. I have to find out "all dates" of the "friday,saturday and sunday" of "every month" through out the year. Then I have to display thaose as result.
Not only the first friday,saturday,sunday date.
How can I do that? Can anyone please help me for solving this problem?
Can any one please give me any hint by sample program code?

Thanks
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is what i did previously,




This just uses two passed in dates for the date ranges and then uses a while loop to go through that range searching for Fridays and then storing the date for every friday found. Also it has to increment the date.

John
[ March 02, 2007: Message edited by: John Bartlett ]
 
Soumya Ghosh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
 
Soumya Ghosh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
thanks for giving idea for pulling all fridays within specified date ranges.

but, I have no provision of specifying two dates such as start date and end date.
User will give only YEAR as input. And depending on that year, I have to list all Friday dates,Saturday dates and sunday dates of that corresponding year and for all 12 months.

Please help me by providing a sample code.
 
author
Posts: 23945
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Soumya Ghosh:
Hi,
thanks for giving idea for pulling all fridays within specified date ranges.

but, I have no provision of specifying two dates such as start date and end date.
User will give only YEAR as input. And depending on that year, I have to list all Friday dates,Saturday dates and sunday dates of that corresponding year and for all 12 months.

Please help me by providing a sample code.



Hate to point out the real obvious... but...

(1) Given a year as the input, isn't the start date January 1st, of that year, and the end date December 31st, of that year?

(2) Given the example, that only checks for Fridays, can't you add a check for Saturday and Sunday too?

Henry
 
Soumya Ghosh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for help.
But I can't understand following line of code-------
for (String friday : fridays)

What does it mean?Can you please clarify me? It's new to me.

Thanks
 
Henry Wong
author
Posts: 23945
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Soumya Ghosh:
Hi,
Thanks for help.
But I can't understand following line of code-------
for (String friday : fridays)

What does it mean?Can you please clarify me? It's new to me.

Thanks



It's the new "foreach" loop that was added with Java 5.0.

Basically, it is just syntactic sugar. The loop...



just compiles to...



Personally, I don't use it myself. Mainly because I have been working in Java for so long, the standard for-loop is now in "muscle memory" for me. The other issue is that the iterator is not in scope, so you can't remove items from the collection correctly.

Henry
 
Soumya Ghosh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
 
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic