Skip to main content
Skip table of contents

WorkingTimeCalculator (deprecated)

The working time calculation functions of the de.softproject.xsl.WorkingTimeCalculator  Java class are deprecated and will be removed in future versions of the X4 BPMS.

Beginning with version 6.0.0 of the X4 BPMS, the (7.4.0-en) Working Time Calculator adapter is available for this purpose.

The  de.softproject.xsl.WorkingTimeCalculator Java class is located within the X4 Server library x4-client.jar (under <X4>\Server\<wildfly>\modules\de\softproject\x4\client\main).

An XSL mapping using this help class cannot be executed in the transformation preview of the Mapping Editor.

Methods for Defining the Working Time

Before you can use the methods for the working time calculation, it is required to define the working time (begin and end of the working day, number of working days per week, holidays etc.) for the WorkingTimeCalculator  object using the following methods.

setHolidays(
java.lang.String holidays)

Sets for a WorkingTimeCalculator object one or several holidays as string of the type java.lang.String and following the pattern yyyy-mm-dd, yyyy-mm-dd, ... and returns a WorkingTimeCalculator object.

Example:  setHolidays('2013-12-24, 2013-12-25, 2013-12-26'), setHolidays('2016-4-15, 2016-4-16, 2016-4-18')

setSpecialDays(
java.lang.StringspecialDays)

Sets for a WorkingTimeCalculator object a time period as string of the type java.lang.String and following the pattern yyyy-mm-dd hh:MM-hh:MM, yyyy-mm-dd hh:MM-hh:MM, ... and returns a WorkingTimeCalculator object. This time period is always calculated as working time and has thus priority over holidays and working times. 

Example: setSpecialDays('2010-12-06 11:30-12:0,2010-01-06 10:30-15:30')

setWorkingDayBegin(
int hr, int min)

Sets for a WorkingTimeCalculator object the beginning of a working day including the hours and minutes as integer numbers and returns a WorkingTimeCalculator object.

Example: setWorkingDayBegin(9,0)

setWorkingDayBegin(
java.lang.String hr, 
java.lang.String min)

Sets for a WorkingTimeCalculator object the beginning of a working day including the hours and minutes as string of the type java.lang.String and returns a WorkingTimeCalculator object.

Example: setWorkingDayBegin('09','00')

setWorkingDayEnd(
int hr, 
int min)

Sets for a WorkingTimeCalculator object the end of a working day including the hours and minutes as integer numbers and returns a WorkingTimeCalculator object.

Example: setWorkingDayEnd(17,0)

setWorkingDayEnd(
java.lang.String hr, 
java.lang.String min)

Sets for a WorkingTimeCalculator object the end of a working day including the hours and minutes as string of the type java.lang.String and returns a WorkingTimeCalculator object.

Example: setWorkingDayEnd('17','00')

setWorkingDays(
java.lang.String days)

Sets for a WorkingTimeCalculator object a list of the working days per week as string of the type java.lang.String and following the pattern <day number>,<day number>,... and returns a WorkingTimeCalculator object. Weekdays are outputted according to java.util.Calendar as numbered list beginning with for Sunday.

Example: setWorkingDays('2,3,4,5,6')

Working Time Calculation Functions

addWorkingTimeMinutes(
WorkingTimeCalculator wtc, 
java.util.Date from, int minutes

Adds to a java.util.Date object any integer number of minutes within the defined working time and outputs a static java.util.Date object.
Prerequisite: a WorkingTimeCalculator object has already been initialized correctly and handed over as first argument within an XSL variable, see Methods for defining the working time

addWorkingTimeMinutesString(
WorkingTimeCalculator wtc
java.util.Date from, int minutes)

Adds to a java.util.Date object any integer number of minutes within the defined working time and outputs a string of the type java.lang.String.
Prerequisite: a WorkingTimeCalculator object has already been initialized correctly and handed over as first argument within an XSL variable, see Methods for defining the working time

Only compatible with Xalan 2.7.1, but not with Saxon 9!

addWorkingTimeMinutesString(
WorkingTimeCalculator wtc
java.lang.String from, int minutes)

Adds to a string according to java.lang.String any integer number of minutes within the defined working time and outputs a string of the type java.lang.String.
Prerequisite: a WorkingTimeCalculator object has already been initialized correctly and handed over as first argument within an XSL variable, see Methods for defining the working time

Only compatible with Xalan 2.7.1, but not with Saxon 9!

Example: addWorkingTimeMinutesString('Thu Jul 11 14:29:24 CEST 2013', 'Mon Jul 18 16:04:55 CEST 2013',200)

dateDiff( java.util.Date from, 
java.util.Date to)

Compares two java.util.Date objects with each other and outputs the difference in milliseconds as static long number.

Only compatible with Xalan 2.7.1, but not with Saxon 9!

dateDiffWorkingMinutes(
WorkingTimeCalculator wtc
java.util.Date from, java.util.Date to)

Compares two java.util.Date objects with each other and outputs the difference within the defined working times in milliseconds as long number.
Prerequisite: a WorkingTimeCalculator object has already been initialized correctly and handed over as first argument within an XSL variable, see Methods for defining the working time

Only compatible with Xalan 2.7.1, but not with Saxon 9!

getOstern(double year)

Determines the Easter date for a year, that has been handed over as four-digit number of the type double and returns a string of the type java.lang.String

Example: getOstern(2014)

getWorkingTimeMinutes(
WorkingTimeCalculator wtc
java.util.Date from, java.util.Date to)

Determines the number of minutes within the defined working times, which lie between a start and an end date of the type java.util.Date, and returns a number of the type double.
Prerequisite: a WorkingTimeCalculator object has already been initialized correctly and handed over as first argument within an XSL variable, see Methods for defining the working time

getWorkingTimeMinutes(
WorkingTimeCalculator wtc
int fromYear, int fromMonth, 
int fromDay, int fromHr, int fromMin)

Determines the number of minutes within the defined working times, which lie between a start date (defined as integer number for year, month, day, hour and minute) and the current date, and returns a number of the type double.
Prerequisite: a WorkingTimeCalculator object has already been initialized correctly and handed over as first argument within an XSL variable, see Methods for defining the working time

getWorkingTimeMinutes(
WorkingTimeCalculator wtc
int fromYear, int fromMonth, 
int fromDay, int fromHr, 
int fromMin, java.util.Date to)

Determines the number of minutes within the defined working times, which lie between a start date (defined as integer number for year, month, day, hour and minute) and an end date of the type java.util.Date, and returns a number of the type double.
Prerequisite: a WorkingTimeCalculator object has already been initialized correctly and handed over as first argument within an XSL variable, see Methods for defining the working time

getWorkingTimeMinutes(
WorkingTimeCalculator wtc
int fromYear, int fromMonth, 
int fromDay, int fromHr, 
int fromMin, int toYear, 
int toMonth, int toDay, 
int toHr, int toMin)

Determines the number of minutes within the defined working times, which lie between a start and an end date (defined as integer number for year, month, day, hour and minute), and returns a number of the type double.
Prerequisite: a WorkingTimeCalculator object has already been initialized correctly and handed over as first argument within an XSL variable, see Methods for defining the working time

Example

HTML/XML
<xsl:stylesheet xmlns:x4time="de.softproject.xsl.TimeHelperDate" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:x4wtc="de.softproject.xsl.WorkingTimeCalculator" 
  exclude-result-prefixes="x4time x4wtc" version="1.0">
  <xsl:output indent="yes" method="xml" media-type="text/xml"></xsl:output>
  <xsl:template match="/">
    <Output>
      <!-- Create new WorkingTimeCalculator object and store it in variable WTC -->
      <xsl:variable select="x4wtc:new()" name="WTC1"></xsl:variable>

      <!-- Get a java.util.date object with current date/time -->
      		<xsl:variable select="x4time:now()" name="date"></xsl:variable>
      		<now><xsl:value-of select="$date"></xsl:value-of></now>

      <!-- Set 2013 holidays to new year's eve and christmas -->
     		<xsl:variable select="x4wtc:setHolidays($WTC1,'2013-1-1, 2013-12-25')" name="WTC2"></xsl:variable>

      <!-- Set extra working time to December 24th from  (Santa's X-mas delivery shift) -->
     	 	<xsl:variable select="x4wtc:setSpecialDays($WTC2,'2013-12-24 23:0-23:59')" name="WTC3"></xsl:variable>

      <!-- Set working day begin time to 9:00 AM for the WTC object variable -->
    	 	<xsl:variable select="x4wtc:setWorkingDayBegin($WTC3,9,0)" name="WTC4"></xsl:variable>

      <!-- Set working day end time to 5:00 PM (17:00) for the WTC object variable -->
      		<xsl:variable select="x4wtc:setWorkingDayEnd($WTC4, 17, 0)" name="WTC5"></xsl:variable>

      <!-- Set working days to Monday, Tuesday, Wednesday, Thursday, Friday for the WTC object variable -->
      		<xsl:variable select="x4wtc:setWorkingDays($WTC5,'2,3,4,5,6')" name="WTC"></xsl:variable>

      <!-- Add 500 working time minutes to a date -->
      		<xsl:variable select="x4wtc:addWorkingTimeMinutes($WTC, $date,500)" name="addWorkingTimeMinutes"></xsl:variable>
      		<addWorkingTimeMinutes><xsl:value-of select="$addWorkingTimeMinutes"></xsl:value-of></addWorkingTimeMinutes>
 
      <!-- Get Easter date for year 2014 -->
      		<xsl:variable select="x4wtc:getOstern(2014)" name="getOstern"></xsl:variable>
      		<getOstern><xsl:value-of select="$getOstern"></xsl:value-of></getOstern>    

      <!-- Calculate working minutes between two java.util.Date objects -->
      		<xsl:variable select="x4wtc:getWorkingTimeMinutes($WTC,$date,$addWorkingTimeMinutes)" name="getWorkingTimeMinutes">			
			</xsl:variable>
      		<getWorkingTimeMinutes type="date"><xsl:value-of select="$getWorkingTimeMinutes"></xsl:value-of></getWorkingTimeMinutes>    
    
	  </Output>
  </xsl:template>
</xsl:stylesheet>

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.