let's do it again, using GregorianCalendar
Few days ago I was listening a client about the framework his company
was producing for a long time. Tips about the workflow, security and several
other common features of a framework. A special
feature gave me a dÃ©jÃ vu: the control of holidays in the
financial modules. Every financial calculus is based on working days and
every framework I've ever seen in my life had also a module for
the calculation of workdays range - subtracting holidays, sundays, etc.
These modules are so identical that I've started to think about the need to include
that feature in the
java.util.GregorianCalendar or some other
implementation of the Calendar Interface.
I know APIs should avoid features from specific applications, such as it was well explained
in a recent entry of the
Eamonn McManus blog. But this special algorithm - the calculus of workdays
within a time interval - is so common that I think it should be included as a
generic feature in a next review of the class GregorianCalendar.
Everyone who already implemented such feature knows about its functionality:
you store a list of holidays, and the Calendar identify the Sundays for you.
The algorithm consists in comparing each day of the time interval with the days
from that holidays list. Quite simple, but quite repetitive for all
One can argue that companies can implement it just once and reuse
the algorithm in the new systems. I agree with that, but I also think such
obvious algorithm should be part of the Java API as a facility.
I was thinking about a Java Specification
Request or just suggest this new feature to the
JDK community, but I prefer to listen you first. I'm not sure if there is
something already supported by the API (I didnÂ´t find any reference about that) and I
also prefer to discuss its utility with you before to go into the formal aspects of a
specification request - a sanity check :).