my dog learned polymorphism
The moose likes Beginning Java and the fly likes No.of SUNDAY's between two dates??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "No.of SUNDAY Watch "No.of SUNDAY New topic

No.of SUNDAY's between two dates???

Swapna Agarwal
Ranch Hand

Joined: Jan 30, 2004
Posts: 37
Could any one tell me a simple logic to get No.of DAY's between 2 dates?
Start date:22/03/04
EndDate: 22/03/03
I want to get No. of SUNDAY's between these two dates.
Could any one tell me simple logic?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33111

Take a look at the Calendar class. It can give you the day of the week for each of your two dates. From there, you can calculate the number of sundays.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

This is not a Servlet question, I'll move it to Java in General (beginnner) for you.
I agree. Here's the link:
subject: No.of SUNDAY's between two dates???
It's not a secret anymore!