Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Calculating Business days in java

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Calculating Business days in java

    Do any body has sample java code to add some specific business days(eg:10 days) to the existing date.I need to exclude weekends and holidays in calculating the expected date.

    Please advise.

    Thanks,
    Kumar


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Calculating Business days in java

    Simple algorithm:

    Use a loop through every day between the two given dates. If it's a business day, increase the business day counter. If it's not, move to the next day.

    You'll need a way to determine if a day is a business day or not. Keep track of holidays in a collection (a hash would lend itself quite well for this). A good "day of the week" algorithm would make determining if it's a weekend or not very easy. There are plenty of these online (search google).

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,543
    Thanks
    24
    Thanked 298 Times in 281 Posts

    Default Re: Calculating Business days in java

    Last year I played around with the Doomsday Rule . I managed to make a program using the steps described. I was surpised it actually worked. Pretty awesome for such a simple set of steps.

Similar Threads

  1. question on calculating
    By meowCat in forum Java Theory & Questions
    Replies: 5
    Last Post: August 9th, 2010, 05:06 PM
  2. Getting date based on days past year
    By aussiemcgr in forum Java Theory & Questions
    Replies: 3
    Last Post: July 14th, 2010, 04:06 PM
  3. Funny business with JFrame, JPanel and JLabel
    By JeffC in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 21st, 2010, 12:26 PM
  4. how do i get only the workig days for a certain month
    By anonimus83 in forum Algorithms & Recursion
    Replies: 2
    Last Post: January 11th, 2010, 10:13 AM
  5. KB/s download speed calculating
    By Kok in forum Java Theory & Questions
    Replies: 2
    Last Post: December 16th, 2009, 02:05 PM