tags:

views:

180

answers:

3

I would like to calculate end date (and time) of an event. I know starting date and duration (in minutes). But:

  1. I have to skip holidays - non-recurrent situation
  2. I have to skip weekends - recurrent situation
  3. I have to not count working time (e.g: from 8:00am till 5:00pm) - recurrent situation, but with finer granularity

Is there a simple way to achieve these cases using Joda time library?

+1  A: 

First you have to define "holidays". Not every locale has the same ones, so this has to be made generic and pluggable.

I don't think it's "simple".

duffymo
In my case holidays are stored in a database. But I wanted to point out that I cannot use: if(dayofweek() == 7) { skip(); }
picca
+1  A: 

Have you looked into Holiday calculation project? it is featured in the Related projects from jodatime and could be useful

raticulin
Looks really good. But I still don't know how to handle working hours. I basically need to fast-forward given date by N-minutes. Skipping working hours, holidays, etc...
picca
+1  A: 

Jodatime will help you -a lot I'd say-, but you'll need to write the logic yourself, a loop skipping some entire days and some times of the day. Not very simple, neither very complex, it seems to me.

leonbloy
Marking as accepted answer, because it's true. According to my researches, there is no simple solution. And Jodatime is definetly helpful.
picca