How to Automatically Rewrite Dates that fall on National Holidays

I would like to introduce a mechanism in which a date data which fall on National Holidays are automatically corrected into a “business day”, for example, for “shipping deadlines”. (Utilization of Options XML / Service Task Add-on)

Hi, there!

In 2017, there is only one substitute holiday.
You must wait for long weekends until 2018, which has 4 substitute holidays.

Questetra BPM Suite service started in 2009.
Since the beginning, I have got requirements such as:

Assessment (input validation) of “business days” upon date entry.
For operation for which deadlines should be handled (precisely) on business days.

Even now, validation upon date entry is not provided.
(I suppose everybody has their own ways, but please bare with us.)

However, it can be possible by combining various functions.

Correction of input dates assessing “business days”

(Not validation at input, but correction at a later Step)

<Solution image: Saturdays, Sundays correction>
Solution image: Saturdays, Sundays correction

<Solution image: Holidays correction>
Solution image: Holidays correction

I would like to show you how to make this possible.

Implementation Method Overview (Using of Options XML / Service Task Add on)

We can almost solve the requirement by doing the following:

If the Date type Data Item is specified on a public holiday, Saturday, Sunday, the date will be corrected according to the designation of “preceding date” or “following date”.

Also, the implicit request for this function “to be able to be used for various tasks” was considered, so we kept that in mind when developing the mechanism.

Based on that, I think the following is a practical method:

* The national holiday information is stored in the Options XML.
* Correct the specified date on national holiday and Saturday and Sunday with an automatic processing Step (Date data correction service) using the service task Add on.

<App diagram>
App diagram

Public Holiday Information (Options XML) Implementation Example

Considering the fact that “it should be able to be used in various tasks”, we would need to use it as an App-shared file.

For the settings, please refer to the following articles:

Register an Options-XML file to which the Process Model Definitions Refer to
Select type data of Data items definition requires a “Candidate list” to be set. If the target List was registered to the system by a User with [System Administrator Authorization], it allows it to be referenceable from each App. More efficiency of modeling, or centralized management of candidate lists will be achieved by doing this.

<Holiday Information (Option XML) Settings Example>

  <item value="2017-01-01" display="New Year's Day" />
  <item value="2017-01-02" display="Transfer holiday for New Year's Day" />
  <item value="2017-01-09" display="Coming of Age Day" />
  <item value="2017-02-11" display="National Foundation Day" />
  <item value="2017-03-20" display="Vernal Equinox Day" />
  <item value="2017-04-01" display="★Questetra Founding anniversary★" />
  <item value="2017-04-29" display="Showa Day" />
  <item value="2017-05-03" display="Constitution Memorial Day" />
  <item value="2017-05-04" display="Greenery Day" />
  <item value="2017-05-05" display="Children's Day" />
  <item value="2017-07-17" display="Marine Day" />
  <item value="2017-08-11" display="Mountain Day" />
  <item value="2017-09-18" display="Respect for the Aged Day" />
  <item value="2017-09-23" display="Autumnal Equinox Day" />
  <item value="2017-10-09" display="Health and Sports Day" />
  <item value="2017-11-03" display="Culture Day" />
  <item value="2017-11-23" display="Labour Thanksgiving Day" />
  <item value="2017-12-23" display="The Emperor's Birthday" />

In this example, “Questetra Founding anniversary” was added on “April 1, 2017” besides Japan’s holidays.

Date Data Correction Service (Service Task Add on) Implementation Example

The Service Task setting is as shown in the following image.
(The file name of the Holiday information Options XML is “HolidayList”)

<Service Task Add on setting screen>
Service Task Add on setting screen

The following is a caveat for setting contents.

* Regarding “Correction date data”, there is no problem using the same data item for the “Specified date data”.
(In such a case, it will be overwritten.)
* “Holiday correction type” is [single-byte] “-” (for preceding date correction) or “+” (for following date correction), other characters will be treated as “-“.

<Service Task Add on Implementation Example>

<?xml version="1.0" encoding="UTF-8"?><service-task-definition>

<label>Date Data Correction Service</label>

  <config name="conf_HolidayMasterFile" required="true" form-type="TEXTFIELD">
    <label>Holidays data master file name</label>
  <config name="conf_TargetDate" required="true" form-type="SELECT" select-data-type="DATE">
    <label>Specified date data (Date type Data Item)</label>
  <config name="conf_CorrectDate" required="true" form-type="SELECT" select-data-type="DATE">
    <label>Corrected date data (Date type Data Item)</label>
  <config name="conf_HolidayCorrectValue" required="true" form-type="TEXTFIELD">
    <label>Holiday correction type preceding date:"-"  following date:"+"</label>

// Public holiday, Saturdays and Sundays Date Correction script (ver. 20170209)
// Correction value / Correct the date based on the holiday data
// Correction by specifying Holiday correction type (preceding date: "-" following date: "+") 
// E.g.: In the case of March 20, 2017 (Monday) to be preceding date will be corrected to Friday, March 17, 2017
// E.g.: In the case of May 6, 2017 (Saturday) to be preceding date will be corrected to Tuesday, May 2, 2017
// E.g.: In the case of May 3, 2017 (Wednesday) to be following date will be corrected to Monday, May 8, 2017
// (c) 2017, Questetra, Inc. (the MIT License)

//// == Config Retrieving ==
var holidayMasterFileName = configs.get( "conf_HolidayMasterFile" ); // return Holidays data master file name
var targetDateNum = configs.get( "conf_TargetDate" );   // (returns Number)
var correctDateNum = configs.get( "conf_CorrectDate" ); // (returns Number)
var holidayCorrectKind = configs.get( "conf_HolidayCorrectValue" );  // (returns Number)

//// == Data Retrieving, Data Define ==
var targetDate = data.get(targetDateNum);
var formatter = new java.text.SimpleDateFormat("yyyy-MM-dd");
var targetDateString = formatter.format(targetDate);

//// == Calculating ==
while ((itemDao.findByValue(holidayMasterFileName,true,targetDateString) == null)||(targetDate.getDay() != 6)||(targetDate.getDay() != 0)){
    targetDateString = formatter.format(targetDate);
    // Holidays check, Correction
    if (itemDao.findByValue(holidayMasterFileName,true,targetDateString) != null){
        if (holidayCorrectKind == "+"){
            targetDate = targetDate.addDays(1);
            targetDate = targetDate.addDays(-1);
    // Saturdays check, Correction
    if (targetDate.getDay() == 6){
        if (holidayCorrectKind == "+"){
            targetDate = targetDate.addDays(2);
            targetDate = targetDate.addDays(-1);
    // Sundays check, Correction
    if (targetDate.getDay() == 0){
        if (holidayCorrectKind == "+"){
            targetDate = targetDate.addDays(1);
            targetDate = targetDate.addDays(-2);

//// == Data Updating ==





By using the Service Task Add on, it will be relatively easy to deploy it for other Apps.
The implementation itself is relatively simple, so if you have other correction rules, I suppose customization according other rules will be easy as well.

For the use of Service Task Add on, please refer to the following reference articles:

Adding an Auto-Step to be Used for Business Process Definition
When you want to automate Processing-steps, such as “Obtaining Number of characters and Hash value”, it is not possible to define them using only standard [Service Task] and [Event] (You must use [Script Task] ). However, you will be able to automate your business easily by importing [Add on XML], such as “Number of Character Counter-addon.xml” or “SHA Hash-addon.xml”, in advance. (Service-Task Add on)

Please consider this for improving the efficiency of automatic processing implementation.

Click HERE (external site) for more info about Japan’s holidays.


Original article in Japanese was posted on 2017-02-28

About Masato Furukubo

Questetra, Inc. Sales Department
View all posts by Masato Furukubo

Prev article - 50. Questetra Tips Automate Processing by Accessing its Own API
Next article - 50. Questetra Tips Can Backlog and Cloud BPM Cooperate?
Another article - Masato Furukubo How to do Multilingual Support of a Process Data Item Name in the Input Screen?