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( | Sets for a Example: |
setSpecialDays( | Sets for a Example: |
setWorkingDayBegin( | Sets for a Example: |
setWorkingDayBegin( | Sets for a Example: |
setWorkingDayEnd( | Sets for a Example: |
setWorkingDayEnd( | Sets for a Example: |
setWorkingDays( | Sets for a Example: |
Working Time Calculation Functions
addWorkingTimeMinutes( | Adds to a |
addWorkingTimeMinutesString( | Adds to a Only compatible with Xalan 2.7.1, but not with Saxon 9! |
addWorkingTimeMinutesString( | Adds to a string according to Only compatible with Xalan 2.7.1, but not with Saxon 9! Example: |
dateDiff( java.util.Date from, | Compares two Only compatible with Xalan 2.7.1, but not with Saxon 9! |
dateDiffWorkingMinutes( | Compares two 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 Example: |
getWorkingTimeMinutes( | Determines the number of minutes within the defined working times, which lie between a start and an end date of the type |
getWorkingTimeMinutes( | 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 |
getWorkingTimeMinutes( | 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 |
getWorkingTimeMinutes( | 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 |
Example
<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>