TimeHelper (deprecated)
The date and time functions of the Java class de.softproject.xsl.TimeHelperDate
provided within XSL mappings are deprecated and will be removed in future versions of the X4 BPMS.
The Java class de.softproject.xsl.TimeHelperDate
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, can't be executed in the Mapping Editor's transformation preview.
Date/Time Methods
addDay(java.util.Date | Adds any integer number of days to a |
addHour(java.util.Date | Adds any integer number of hours to a |
addMillisecond(java.util.Date | Adds any integer number of millisecond to a |
addMinute(java.util.Date | Adds any integer number of minutes to a |
addMonth(java.util.Date | Adds any integer number of months to a |
addSecond(java.util.Date | Adds any integer number of seconds to a |
addYear(java.util.Date | Adds any integer number of years to a |
asMilliseconds( | Returns a |
canParse( | Checks the format of a date with the optional parameter |
canParseDefaultFormat( | Checks if the used date format with the optional parameter |
createDefaultFormat( | Outputs the current date (with the optional parameter |
createFormat( | Outputs the current date (with the optional parameter For more information regarding the date and time formats, consult http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html |
differenceInMilliseconds( | Calculates the difference between two |
format(java.lang.String format, | Formats a |
formatDefaultFormat( | Formats a |
fromMilliseconds(long milli) | Converts a date in milliseconds into a |
getDay(java.util.Date date, | Determines the day from a |
getDayOfWeek( | Determines the weekday from a The counting of the weekdays begins on Sunday with 1:
|
getDayOfWeekInMonth( | Determines the weekday within a month (e. g. which Tuesday of the month) from a |
getDayOfYear(java.util.Date date, | Determines the day within a year from a |
getHour(java.util.Date date, | Determines the hours from a |
getMilliSecond(java.util.Date date, | Determines the milliseconds from a |
getMinute(java.util.Date date, | Determines the minutes from a |
getMonth(java.util.Date date, | Determines the month from a The counting of the months begins with 0:
|
getSecond(java.util.Date date, | Determines the seconds from a |
getWeekOfMonth( | Determines the week of the month from a |
getWeekOfYear( | Determines the week number from a |
getYear(java.util.Date date, | Determines the year from a |
isAfter( java.util.Date date, | Checks if a |
isBefore(java.util.Date date, | Checks if a |
now() | Determines the current date and outputs it as |
parse(java.lang.String format, | Reads a date in |
parseDefaultFormat( | Reads a date in |
setBeginOfDay(java.util.Date date, | Outputs for the entered |
setBeginOfMonth( | Outputs for the entered |
setBeginOfYear( | Outputs for the entered |
setDay(java.util.Date date, | Outputs for the entered If the entered number is higher than the actual number of days within the respective month, the difference will be added to the following month(s). |
setDayOfYear(java.util.Date date, | Outputs for the entered |
setEndOfDay(java.util.Date date, | Outputs for the entered |
setEndOfMonth(java.util.Date date, | Outputs for the entered |
setEndOfYear(java.util.Date date, | Outputs for the entered |
setHour(java.util.Date date, | Outputs for the entered If the entered number is higher than 24, the difference will be added to the following day(s). |
setMillisecond(java.util.Date date, | Outputs for the entered |
setMinute(java.util.Date date, | Outputs for the entered If the entered number is higher than 60, the difference will be added to the following hour(s). |
setMonth(java.util.Date date, | Outputs for the entered The counting of the months begins with 0:
If the entered number is higher than 11, the difference will be added to the following year(s). |
setSecond(java.util.Date date, | Outputs for the entered If the entered number is higher than 60, the difference will be added to the following minute(s). |
setYear(java.util.Date date, | Outputs for the entered |
Example
Representative for all methods, in this example variables with one method call are initialized and their return values are outputted in an XML element. For this purpose, the two namespaces x4time
for the time helper class and sdf
for the Java SimpleDateFormat are defined in the XSL stylesheet's head first. Moreover, in the variables date
and from_date
two variables with a java.util.Date
object are initialized as sample data for future use.
<xsl:stylesheet xmlns:sdf="java.text.SimpleDateFormat" xmlns:x4time="de.softproject.xsl.TimeHelperDate" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" method="xml" media-type="text/xml"></xsl:output>
<xsl:template match="/">
<!-- Get date/time values -->
<xsl:variable select="x4time:now()" name="date"></xsl:variable>
<xsl:variable select="x4time:addDay($date, 1)" name="from_date"></xsl:variable>
<Output>
<!-- Output method return values -->
<now><xsl:value-of select="$date"></xsl:value-of></now>
<!-- method addDay -->
<xsl:variable select="x4time:addDay($date, 8)" name="addDayDate">
</xsl:variable>
<addDay type="date">
<xsl:value-of select="$addDayDate"></xsl:value-of>
</addDay>
<!-- method asMilliseconds -->
<xsl:variable select="x4time:asMilliseconds($date)" name="asMillisecondsDate">
</xsl:variable>
<asMilliseconds type="date">
<xsl:value-of select="$asMillisecondsDate"></xsl:value-of>
</asMilliseconds>
<!-- method canParse with Timezone-->
<xsl:variable select="x4time:canParse('yyyy-MM-dd', 'CET','2013.07.111')"
name="canParseWithTimezone">
</xsl:variable>
<canParse type="withTimezone">
<xsl:value-of select="$canParseWithTimezone"></xsl:value-of>
</canParse>
<!-- method canParseDefaultFormat -->
<xsl:variable select="x4time:canParseDefaultFormat('2013-07-111 16:56:45.123')" name="canParseDefaultFormatSimple">
</xsl:variable>
<canParseDefaultFormat type="simple">
<xsl:value-of select="$canParseDefaultFormatSimple"></xsl:value-of>
</canParseDefaultFormat>
<!-- method createDefaultFormat with timezone -->
<xsl:variable select="x4time:createDefaultFormat('PST')" name="sdf_default_withTimezone">
</xsl:variable>
<createDefaultFormatTz type="withTimezone">
<xsl:value-of select="sdf:format($sdf_default_withTimezone, $date)"></xsl:value-of>
</createDefaultFormatTz>
<!-- method createFormat with timezone -->
<xsl:variable select="x4time:createFormat('yyyy-MMM-dd EE','CET')" name="sdf_simpleWithTimezone">
</xsl:variable>
<createFormatTz type="withTimezone">
<xsl:value-of select="sdf:format($sdf_simpleWithTimezone, $date)"></xsl:value-of>
</createFormatTz>
<!-- method differenceInMilliseconds: date to date -->
<xsl:variable select="x4time:differenceInMilliseconds($date, $from_date)" name="differenceInMillisecondsDate">
</xsl:variable>
<differenceInMilliseconds type="date">
<xsl:value-of select="$differenceInMillisecondsDate"></xsl:value-of>
</differenceInMilliseconds>
<!-- method format with Timezone -->
<xsl:variable select="x4time:format('yyyy-MM-dd z','CET',$date)" name="formatWithTimezone">
</xsl:variable>
<formatTZ type="withTimezone">
<xsl:value-of select="$formatWithTimezone"></xsl:value-of>
</formatTZ>
<!-- method formatDefaultFormat with timezone -->
<xsl:variable select="x4time:formatDefaultFormat('PST',$date)" name="formatDefaultFormatWithTimezone">
</xsl:variable>
<formatDefaultFormat type="withTimezone">
<xsl:value-of select="$formatDefaultFormatWithTimezone"></xsl:value-of>
</formatDefaultFormat>
<!-- method fromMilliseconds -->
<xsl:variable select="x4time:fromMilliseconds(1374483531161)" name="fromMilliseconds">
</xsl:variable>
<fromMilliseconds type="date">
<xsl:value-of select="$fromMilliseconds"></xsl:value-of>
</fromMilliseconds>
<!-- method getDayOfWeek with timezone -->
<xsl:variable select="x4time:getDayOfWeek($date, PST)" name="getDayOfWeekWithTimezone">
</xsl:variable>
<getDayOfWeekTZ type="withTimezone">
<xsl:value-of select="$getDayOfWeekWithTimezone"></xsl:value-of>
</getDayOfWeekTZ>
<!-- method isAfter -->
<xsl:variable select="x4time:isAfter($date, $from_date)" name="isAfter">
</xsl:variable>
<isAfter type="date">
<xsl:value-of select="$isAfter"></xsl:value-of>
</isAfter>
<!-- method now -->
<xsl:variable select="x4time:now()" name="now"></xsl:variable>
<now type="date">
<xsl:value-of select="$now"></xsl:value-of>
</now>
<!-- method parse with timezone -->
<xsl:variable select="x4time:parse('yyyy-MM-dd','PST','2013-07-22')" name="parseWithTimezone">
</xsl:variable>
<parseTZ type="withTimezone">
<xsl:value-of select="$parseWithTimezone"></xsl:value-of>
</parseTZ>
<!-- method parseDefaultFormat with timezone -->
<xsl:variable select="x4time:parseDefaultFormat('PST','2013-07-22 05:24:30.376')" name="parseDefaultFormatWithTimezone">
</xsl:variable>
<parseDefaultFormatTZ type="withTimezone">
<xsl:value-of select="$parseDefaultFormatWithTimezone"></xsl:value-of>
</parseDefaultFormatTZ>
<!-- method setBeginOfDay -->
<xsl:variable select="x4time:setBeginOfDay($date)" name="setBeginOfDay">
</xsl:variable>
<setBeginOfDay type="date">
<xsl:value-of select="$setBeginOfDay"></xsl:value-of>
</setBeginOfDay>
<!-- method setDay with timezone -->
<xsl:variable select="x4time:setDay($date, 32, PST)" name="setDayDateWithTimezone">
</xsl:variable>
<setDayTZ type="WithTimezone">
<xsl:value-of select="$setDayDateWithTimezone"></xsl:value-of>
</setDayTZ>
<!-- method setEndOfDay -->
<xsl:variable select="x4time:setEndOfDay($date)" name="setEndOfDay"></xsl:variable>
<setEndOfDay type="date">
<xsl:value-of select="$setEndOfDay"></xsl:value-of>
</setEndOfDay>
<!-- method setMinute with Timezone -->
<xsl:variable select="x4time:setMinute($date, 72)" name="setMinuteDate"></xsl:variable>
<setMinuteTZ type="date">
<xsl:value-of select="$setMinuteDate"></xsl:value-of>
</setMinuteTZ>
</Output>
</xsl:template>
</xsl:stylesheet>