skip to main content
Corticon Studio: Rule Language Guide : Formatting Date, Time, and DateTime properties

Try Corticon Now

Formatting Date, Time, and DateTime properties

DateTime information may take many different formats. Corticon Studios use a common source of acceptable DateTime, Date Only, and Time Only formats, also known as masks.
For example, a date mask may specify yyyy-MM-dd as an acceptable date format, which means that an attribute of type DateTime (or Date) may hold or contain data that conforms to this format. '2013-04-12' conforms to this mask; 'April 12th,2013' does not.
For proper execution, it is important to ensure that date formats used during rule development and testing (and are included in the rule builders' Corticon Studio installations) are also present in the Corticon Server's installation.
Most commercial databases represent dates as DateTimes. Such DateTimes are frequently stored as UTC, namely the number of milliseconds that have transpired from an arbitrary epoch (for example, 1/1/1970 00:00:00 GMT); this is not a universal standard but is a very popular convention. UTC dates can be rendered in the user's local time zone, but this is merely a matter of presentation. A UTC represents a simultaneous point in time for two observers regardless of where on earth they reside.
However, some date or time concepts, such as holiday, cannot be expressed conveniently as a discrete time point. Christmas (12/25/XX) actually denotes different time frames depending on the observers' time zones; thus, Corticon carries (that is, holds in memory) all dates in GMT with the time portion zeroed (that is, midnight). This approach addresses the holiday problem because a user can enter holiday dates into the database and not have them shift when they are rendered in the user's local time zone.
Carrying GMT dates should be transparent to the user. Dates expressed as strings in incoming XML are parsed and the proper data type is inferred; for dates, they are immediately instantiated as GMT and rendered back in GMT with no conversion.

Setting and modifying masks

Date/time masks are stored as a set of defaults that can be replaced by listing preferred values in the file located at your work directory root – or, in Studio, the preferred location specified in Preferences.Corticon Studio's DateTime datatype uses both date and time data. The Date datatype handles only date information, and the Time datatype handles only time information.
The Corticon XML Translator will maintain the consistency of DateTime, Date, and Time values from input to output documents as long as the masks that are used are contained in the lists.
Note: Property settings you list in your do not append to an existing list, they replace the default values. For example, if you want to add a new DateTime mask to the built-in list, be sure to include all the masks you intend to use, not just the new one. If your file contains only the new mask, then it will be the only mask Corticon uses.
There is only one Date datatype. It handles dates, times, and date/times. A Date attribute is designated as date, time, or date/time depending on which of the masks below are matched. This designation changes the behavior of Date comparison operators.
The dateformat, timeformat, and datetimeformat, Date masks process incoming date/times on request XML payloads, insert date/times into output response XML payloads, parse entries made in the Studio Rulesheets, Vocabulary, and Testsheets, and to display any date/time in Studio.
The first entry for each dateformat, datetimeformat, and timeformat is the default mask. For example, the built-in operator today always returns the current date in the default dateformat mask. 
The function now returns the current date in the default datetimeformat.The entries can be altered but must conform to the patterns/masks supported by the Java class SimpleDateFormat in the java.text package.
MMM d, yyyy;
MMMMM d, yyyy
MM/dd/yy h:mm:ss a;
MM/dd/yyyy h:mm:ss a;
M/d/yy h:mm:ss a;
M/d/yyyy h:mm:ss a;
yyyy/MM/dd h:mm:ss a;
yyyy/M/d h:mm:ss a;
yy/MM/dd h:mm:ss a;
yy/M/d h:mm:ss a;
MMM d, yyyy h:mm:ss a;
MMMMM d, yyyy h:mm:ss a;

MM/dd/yy H:mm:ss;
MM/dd/yyyy H:mm:ss;
M/d/yy H:mm:ss;
M/d/yyyy H:mm:ss;
yyyy/MM/dd H:mm:ss;
yyyy/M/d H:mm:ss;
yy/MM/dd H:mm:ss;
yy/M/d H:mm:ss;
MMM d, yyyy H:mm:ss;
MMMMM d, yyyy H:mm:ss;

MM/dd/yy hh:mm:ss a;
MM/dd/yyyy hh:mm:ss a;
M/d/yy hh:mm:ss a;
M/d/yyyy hh:mm:ss a;
yyyy/MM/dd hh:mm:ss a;
yyyy/M/d hh:mm:ss a;
yy/MM/dd hh:mm:ss a;
yy/M/d hh:mm:ss a;
MMM d, yyyy hh:mm:ss a;
MMMMM d, yyyy hh:mm:ss a;

MM/dd/yy HH:mm:ss;
MM/dd/yyyy HH:mm:ss;
M/d/yy HH:mm:ss;
M/d/yyyy HH:mm:ss;
yyyy/MM/dd HH:mm:ss;
yyyy/M/d HH:mm:ss;
yy/MM/dd HH:mm:ss;
yy/M/d HH:mm:ss;
MMM d, yyyy HH:mm:ss;
MMMMM d, yyyy HH:mm:ss;

MM/dd/yy h:mm:ss a z;
MM/dd/yyyy h:mm:ss a z;
M/d/yy h:mm:ss a z;
M/d/yyyy h:mm:ss a z;
yyyy/MM/dd h:mm:ss a z;
yyyy/M/d h:mm:ss a z;
yy/MM/dd h:mm:ss a z;
yy/M/d h:mm:ss a z;
MMM d, yyyy h:mm:ss a z;
MMMMM d, yyyy h:mm:ss a z;

MM/dd/yy H:mm:ss z;
MM/dd/yyyy H:mm:ss z;
M/d/yy H:mm:ss z;
M/d/yyyy H:mm:ss z;
yyyy/MM/dd H:mm:ss z;
yyyy/M/d H:mm:ss z;
yy/MM/dd H:mm:ss z;
yy/M/d H:mm:ss z;
MMM d, yyyy H:mm:ss z;
MMMMM d, yyyy H:mm:ss z;

MM/dd/yy hh:mm:ss a z;
MM/dd/yyyy hh:mm:ss a z;
M/d/yy hh:mm:ss a z;
M/d/yyyy hh:mm:ss a z;
yyyy/MM/dd hh:mm:ss a z;
yyyy/M/d hh:mm:ss a z;
yy/MM/dd hh:mm:ss a z;
yy/M/d hh:mm:ss a z;
MMM d, yyyy hh:mm:ss a z;
MMMMM d, yyyy hh:mm:ss a z;

MM/dd/yy HH:mm:ss z;
MM/dd/yyyy HH:mm:ss z;
M/d/yy HH:mm:ss z;
M/d/yyyy HH:mm:ss z;
yyyy/MM/dd HH:mm:ss z;
yyyy/M/d HH:mm:ss z;
yy/MM/dd HH:mm:ss z;
yy/M/d HH:mm:ss z;
MMM d, yyyy HH:mm:ss z;
MMMMM d, yyyy HH:mm:ss z
h:mm:ss a;
h:mm:ss a z;
H:mm:ss z;
hh:mm:ss a;
hh:mm:ss a z;
HH:mm:ss z
When com.corticon.crml.OclDate.locale=true, it will override the default datetime mask and use the locale mask as the date style type defined by com.corticon.crml.OclDate.datetype and the time style type defined by com.corticon.crml.OclDate.timetypevalue for datetype and timetype are defined as values of java.text.DateFormat enums: FULL = 0, LONG = 1, MEDIUM = 2, SHORT = 3 .

If permissive is true (default), then the Corticon date/time parser will be lenient when handling incoming or entered date/times, trying to find a match even if the pattern is not contained in the mask lists. If false, then any incoming or entered date/time must strictly adhere to the patterns defined by dateformat,   datetimeformat,   timeformat.
Default patterns are for United States and other countries that follow the US conventions on date/times.
com.corticon.crml.OclDate.permissive =true
By default, when the value of now is pinned, the milliseconds are set to zero. This property can specify how to deal with the nano seconds (which can affect the milliseconds).
*Value of ZERO_MILLIS sets the nanos to 0 (which also sets milliseconds to zero)
*Value of ZERO_NANOS sets only the last 3 digits of the nanos to zero (which does not modify millis)
*Value of NO_ZERO does not modify the nanos (This has shown some rare side effects where datetime appears equal however the hidden nanos values cause comparison to be not equal)
Default value is ZERO_MILLIS
If maskliterals is true (default), the system will parse strings and dates more quickly by checking for the presence of mask literals (for example, /, -, : or ,) before consulting the date masks (an expensive process). If a string does not contain any of the mask literal characters, it can be immediately deemed a string (as opposed to a date).
com.corticon.crml.OclDate.maskliterals =true

Mask patterns

To take advantage of this feature, all user-specified date masks must contain at least one literal character. If any user-specified masks contain exclusively date pattern characters (for example, "MMddyy"), maskliterals must be set to false in order to prevent the system from misinterpreting date literals (for example, '123199') as simple strings.
These properties deal with the way Corticon Studio and Corticon Server handle date/time formats. Preset formats -- referred to as masks - are used to:
*Process incoming date/times on request XML payloads.
*Insert date/times into output response XML payloads.
*Parse entries made in the Corticon Studio Rulesheets, Vocabulary, and Tests.
*To display any date/time in Corticon Studio.
Masks are divided into 3 categories: dateformat, datetimeformat, timeformat.
Use the following chart to decode the date mask formats:
The following symbols are used in date/time masks:
Era designator
G = {AD, BC}
yy = {00..99}
yyyy = {0000..9999}
Week year
YY = {00..99}
YYYY = {0000..9999}
Month in year
Text or Number
M = {1..12}
MM = {01..12}
MMM = {Jan..Dec}
MMMM = {January..December}
Week in year
w = {1..53}
ww = {01..53}
Week in month
W = {1..6}
Day in year
D = {0..366}
DDD = {000..366}
Day in month
d = {1..31}
dd = {01..31}
Day of week in month
F = {0..6}
Day name in week
E, EE, or EEE = {Sun..Sat}
EEEE = {Sunday..Saturday}
Day number of week (1 = Monday, ..., 7 = Sunday)
u = {1..7}
AM/PM marker
a = {AM, PM}
Hour in 24-hour format (0-23)
H = {0..23}
HH = {00..23}
Hour in day (1-24)
k = {1..24}
kk = {01..24}
Hour in AM/PM (0-11)
K = {1..12}
KK = {01..12}
Hour in AM or PM
h = {1..12}
hh = {01..12}
Minute in hour
m = {0..59}
mm = {00..59}
Second in minute
s = {0..59}
ss = {00..59}
Millisecond in minute
S = {0..999}
SSS = {000..999}
General time zone
z, zz, or zzz = abbreviated time zone
zzzz = full time zone
RFC 822 time zone
Z,ZZ, or ZZZ = abbreviated time zone
ZZZZ = full time zone
ISO 8601 time zone
X, XX, or XXX = abbreviated time zone
XXXX = full time zone
escape character used to insert text
single quote
Any characters in the pattern that are not in the ranges of [a..z] and [A..Z] will be treated as quoted text. For instance, characters like {:, ., <space>, #, @} will appear in the resulting time text even they are not embraced within single quotes. A pattern containing any invalid pattern letter will result in a thrown exception during formatting or parsing.
Sample Pattern
Resulting Formatted Date
yyyy.MM.dd G 'at' hh:mm:ss z
2013.07.10 AD at 15:08:56 PDT
EEE, MMM d, ''yy
Wed, Jul 10, '13
h:mm a
12:08 PM
hh 'o''clock' a, zzzz
12 o'clock PM, Pacific Daylight Time
K:mm a, z
0:00 PM, PST
yyyy.MMMM.dd G h:mm a
2013.July.10 AD 12:08 PM
Note: See SimpleTimeFormat Javadocs for more detailed information.