Try OpenEdge Now
skip to main content
BP Server Developer's Guide
Business calendar : Calculating the duration
 

Calculating the duration

The calculation of due date requires the start time and the duration. Whether the duration specified by the user is in seconds, minutes, hours, days, months or year, BP Server converts it into milliseconds. This duration in milliseconds is used to calculate the due date using the specific calendar.
BP Server supports the duration calculation using the Duration object. In this implementation for converting the days into hours, a factor of 24 is used. Note that this factor does not consider working hours as 8.
For converting months into days, a constant factor of 30 is used irrespective of the month. For converting years into days, a constant factor of 365 is used even for a leap year. Thus, the "month" and "year" conversions are not exact and might lead to slight digression from the due date expected by the user. However, users can use other duration units, such as "days", "hours", "minutes", and "seconds", to accurately specify the time.
For example,
Duration duration = new Duration(Duration ("6d");
System.out.println("time:" + duration.getTime());
The getTime() method returns the duration in milliseconds.
If the duration specified by the user is 6 days, then it does not correspond to 6 business days. The duration is converted to hours, using 6 times 24 hours giving a value of 144 hours. If one business day equals 8 hours, then this duration amounts to 18 business days.
* Working hours for regular business hours
* Working hours for special business hours
* Working hours for half-day holiday