OpenWGA 7.10 - TMLScript reference

Method :


On object WGA
Usage Creates a Java Calendar object offering diverse functionality to modify date values
Description The Calendar object takes date/time information from a date object and offers methods to modify it on a single field basis. The result of the modification is stored inside the Calendar object until you use method getTime() to again return a real Date object that presents the modified dates.

The Calendar object is part of the Java API, and therefor entirely documented on the JavaSE API Documentation.

However the methods mostly used on this object are:

Calendar.add(fieldConstant, value)

Modifies a single field of the date/time. You must determine the value to modifiy as a constant, that you can retrieve from the Calendar object itself. The most frequently used field constants are:

Calendar.HOUR_OF_DAY  (24 hours day)

The value to add to the field can be positive or negative.

The calendar watches for integrity of the represented date value. If you add a number to a single field that makes it larger as possible it also increases the next higher field. For example adding 5 days to a date of May the 31th will result in June the 5th.


Returns the modified value again as a date object which you can continue to use in TMLScript.

For backward compatibility there still is a method "createCalendar()" available on TMLContext whose use is discouraged since OpenWGA 5.3.

Parameters date (Date, optional):
A date object to be modified. If omitted the calendar will be initialized with the current date/time.
Return value Java-Objekt vom Typ java.util.Calendar.
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Examples Following example creates a calendar based on a Date, subtracts 5 days from it and returns the modified date as Date object.

var calendar = WGA.createCalendar(anotherDate);
calendar.add(calendar.DAY_OF_MONTH, -5);
return calendar.time;