Skip to main content
Skip table of contents

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 
date, int amount)

Adds any integer number of days to a java.util.Date object and returns a static java.util.Date object

addHour(java.util.Date 
date, int amount)

Adds any integer number of hours to a java.util.Date object and returns a static java.util.Date object

addMillisecond(java.util.Date 
date, int amount)

Adds any integer number of millisecond to a java.util.Date object and returns a static java.util.Date object

addMinute(java.util.Date 
date, int amount)

Adds any integer number of minutes to a java.util.Date object and returns a static java.util.Date object

addMonth(java.util.Date 
date, int amount)

Adds any integer number of months to a java.util.Date object and returns a static java.util.Date object

addSecond(java.util.Date 
date, int amount)

Adds any integer number of seconds to a java.util.Date object and returns a static java.util.Date object

addYear(java.util.Date 
date, int amount)

Adds any integer number of years to a java.util.Date object and returns a static java.util.Date object

asMilliseconds(
java.util.Date date)

Returns a java.util.Date object as static long number containing the time since 1.1.1970 in milliseconds

canParse(
java.lang.String format, 
[java.lang.String timezone,] 
java.lang.String value)

Checks the format of a date with the optional parameter timezone for the timezone and returns a static boolean object
In this case, only the format and not the result's validity is checked.

canParseDefaultFormat(
[java.lang.String timezone,]
java.lang.String value)

Checks if the used date format with the optional parameter timezone for the timezone corresponds to the default format and returns a static boolean object

createDefaultFormat(
[java.lang.String timezone])

Outputs the current date (with the optional parameter timezone for a specific timezone) in the default format static java.text.SimpleDateFormat

createFormat(
java.lang.String format, 
java.lang.String timezone])

Outputs the current date (with the optional parameter timezone for a specific timezone) in the format static java.text.SimpleDateFormat

For more information regarding the date and time formats, consult http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

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

Calculates the difference between two java.util.Date objects in milliseconds and returns a static long number

format(java.lang.String format, 
[java.lang.String timezone,] 
java.util.Date date)

Formats a java.util.Date object with optional parameter timezone for the timezone into a static java.lang. String object

formatDefaultFormat(
[java.lang.String timezone,]
java.util.Date date)

Formats a java.util.Date object with optional parameter timezone for the timezone into an object with the default format static java.lang. String

fromMilliseconds(long milli)

Converts a date in milliseconds into a static java.util.Date object

getDay(java.util.Date date, 
[java.lang.String timezone])

Determines the day from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as static int object

getDayOfWeek(
java.util.Date date, [
java.lang.String timezone])

Determines the weekday from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as static int object

The counting of the weekdays begins on Sunday with 1:

  • Sunday: 1

  • Monday: 2

  • Tuesday: 3

  • Wednesday: 4

  • Thursday: 5

  • Friday: 6

  • Saturday: 7

getDayOfWeekInMonth(
java.util.Date date, [
java.lang.String timezone])

Determines the weekday within a month (e. g. which Tuesday of the month) from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

getDayOfYear(java.util.Date date, 
[java.lang.String timezone])

Determines the day within a year from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

getHour(java.util.Date date, 
[java.lang.String timezone])

Determines the hours from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

getMilliSecond(java.util.Date date, 
[java.lang.String timezone])

Determines the milliseconds from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

getMinute(java.util.Date date, 
[java.lang.String timezone])

Determines the minutes from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

getMonth(java.util.Date date, 
java.lang.String timezone])  

Determines the month from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

The counting of the months begins with 0:

  • January: 0

  • February: 1

  • March: 2

  • April: 3

  • May: 4

  • June: 5

  • July: 6

  • August: 7

  • September: 8

  • October: 9

  • November: 10

  • December: 11

getSecond(java.util.Date date, 
[java.lang.String timezone])

Determines the seconds from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

getWeekOfMonth(
java.util.Date date, 
[java.lang.String timezone])

Determines the week of the month from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

getWeekOfYear(
java.util.Date date, 
[java.lang.String timezone])

Determines the week number from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

getYear(java.util.Date date, 
[java.lang.String timezone])

Determines the year from a java.util.Date object with optional parameter timezone for the timezone, and outputs it as integer number of the type static int

isAfter( java.util.Date date, 
java.util.Date reference)

Checks if a java.util.Date object lies before a reference object of the same type, and outputs a boolean object

isBefore(java.util.Date date, 
java.util.Date reference)

Checks if a java.util.Date object lies after a reference object of the same type, and outputs a boolean object

now()

Determines the current date and outputs it as static java.util.Date object

parse(java.lang.String format, 
[java.lang.String timezone,]
java.lang.String value)

Reads a date in java.lang.String format with optional parameter timezone for the timezone, and returns a static java.util.Date object

parseDefaultFormat(
[java.lang.String timezone,]
java.lang.String value)

Reads a date in java.lang.String format with optional parameter timezone for the timezone, and returns a static java.util.Date object in the default format

setBeginOfDay(java.util.Date date, 
[java.lang.String timezone])

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the beginning of the day as static java.util.Date object

setBeginOfMonth(
java.util.Date date, 
[java.lang.String timezone])

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the beginning of the month as static java.util.Date object

setBeginOfYear(
java.util.Date date, 
java.lang.String timezone])

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the beginning of the year as static java.util.Date object

setDay(java.util.Date date, 
[java.lang.String timezone], 
int amount)

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the day of the month as static java.util.Date object

 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,
[java.lang.String timezone], 
int amount)

Outputs for the entered java.util.Date object with optional parameter timezone, the timezone of the date as static java.util.Date object

setEndOfDay(java.util.Date date, 
[java.lang.String timezone])

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the end of the day as static java.util.Date object

setEndOfMonth(java.util.Date date,
[java.lang.String timezone])

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the end of the month as static java.util.Date object

setEndOfYear(java.util.Date date, 
[java.lang.String timezone])

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the end of the year as static java.util.Date object

setHour(java.util.Date date,
[java.lang.String timezone,] 
int amount)

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the number of hours as static java.util.Date object

If the entered number is higher than 24, the difference will be added to the following day(s).

setMillisecond(java.util.Date date,
[java.lang.String timezone,] 
int amount)

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the number of milliseconds as static java.util.Date object

setMinute(java.util.Date date,
[java.lang.String timezone,] 
int amount)

Outputs for the entered java.util.Date object (with optional parameter timezone for the timezone) the number of minutes as static java.util.Date object

If the entered number is higher than 60, the difference will be added to the following hour(s).

setMonth(java.util.Date date,
[java.lang.String timezone,] 
int amount)

Outputs for the entered java.util.Date object with optional parameter timezone for the timezone the month as static java.util.Date object

The counting of the months begins with 0:

  • January: 0

  • February: 1

  • March: 2

  • April: 3

  • May: 4

  • June: 5

  • July: 6

  • August: 7

  • September: 8

  • October: 9

  • November: 10

  • December: 11

If the entered number is higher than 11, the difference will be added to the following year(s).

setSecond(java.util.Date date,
[java.lang.String timezone,] 
int amount)

Outputs for the entered java.util.Date object with optional parameter timezone for the timezone the seconds as static java.util.Date object

If the entered number is higher than 60, the difference will be added to the following minute(s).

setYear(java.util.Date date,
[java.lang.String timezone,] 
int amount)

Outputs for the entered java.util.Date object with optional parameter timezone for the timezone the year as static java.util.Date object

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.

HTML/XML
<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>

JavaScript errors detected

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

If this problem persists, please contact our support.