parseDate()

parsers.parseDate(format, sourceText)

Parses a string containing a date and/or timestamp specification in a particular structured format.

Parameters

format
Format: string
Purpose: Describes the expected layout of the individual date/time components within the sourceText argument.
The format string can contain the following (case-sensitive) placeholders:
yy
Two-digit year. For example, 99 for 1999.
yyyy
Four-digit year. For example, 1999.
MMMM
Full month name. For example, July.
MMM
Three-letter month abbreviation. For example, Jul for July.
MM
Two-digit numeric month. For example, 07 for July.
dd
Two-digit day in month. For example, 23.
HH
Two-digit hour-in-day. For example, 00 thru 23 inclusive, for 24-hour time.
hh
Two-digit hour-in-day. For example, 01 thru 12 inclusive, for 12-hour time.
mm
Two-digit minute in hour. For example, 00 thru 59 inclusive.
ss
Two-digit second in minute. For example, 00 thru 59 inclusive.
SSS
Three-digit millisecond value. For example, 000 thru 999 inclusive.
z
Time zone. For example, UTC+10:00.
Z
RFC 822 time zone. For example, +1000 for 10 hours ahead of UTC.
a
AM/PM marker. For example, AM or PM.
To escape a letter (indicate that it needs to be matched verbatim), enclose it in single quotes '. To match a single quote directly, write two single quotes consecutively '' (no space between quotes).
Note: All the sequences supported by the Java Foundation Class java.text.SimpleDateFormat are permitted for this parameter. For more information, see http://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

The letters 'G', 'Y', 'L', 'W', 'w', 'D', 'F', 'E', 'u', 'k', 'K', 'X' are also supported as per the above Java specification.

Any other characters, such as punctuation, spaces or letters not mentioned above, will be matched verbatim.

sourceText
Format: string
Purpose: Specifies the date string to be parsed.

Example: A parseDate request

The following example is a parseDate request containing a string for the format argument and sourceText of the date to parse.

parsers.parseDate("dd/MM/yyyy HH:mm:ss", "31/12/1999 23:59:59")

Result

Returns a java.util.Date instance containing the parsed date/timestamp.

Example: A returned parseDate request

This example shows the returned parseDate request.

31st December 1999 at 11:59:59pm