Creates a DateTime from a string. This action parses a date/time value that arrives as text — such as from an EDI segment, flat file, or API response — and converts it into a proper DateTime object that can be used by other ruleset actions for calculation, comparison, or reformatting.
| Property | Type | Description |
|---|---|---|
| DateTimeString | String | The source date/time value as a text string, formatted consistently with the FormatPattern provided. |
| FormatPattern | String | The pattern syntax, mostly compatible with java.text.SimpleDateFormat. This tells the action exactly how to interpret the characters in the DateTimeString. |
FormatPattern Syntax Reference
The FormatPattern uses letter codes to represent each component of the date and time. The most commonly used tokens are:
| Token | Meaning | Example |
|---|---|---|
yyyy |
Four-digit year | 2024 |
yy |
Two-digit year | 24 |
MM |
Month (01–12) | 06 |
MMM |
Abbreviated month name | Jun |
dd |
Day of month (01–31) | 15 |
HH |
Hour in 24-hour format (00–23) | 13 |
hh |
Hour in 12-hour format (01–12) | 01 |
mm |
Minutes (00–59) | 45 |
ss |
Seconds (00–59) | 30 |
a |
AM/PM marker | PM |
z |
Timezone abbreviation | EST |
Note: Month (
MM) and minutes (mm) use different cases — always use uppercaseMMfor month and lowercasemmfor minutes to avoid parsing errors.
Examples
DateTimeString: 2016/05/31 11:22:10 FormatPattern: yyyy/MM/dd HH:mm:ss Return: 2016-05-31T11:22:10.000-04:00
Additional pattern examples:
| DateTimeString | FormatPattern | Result |
|---|---|---|
20240615 |
yyyyMMdd |
2024-06-15T00:00:00 |
06/15/2024 |
MM/dd/yyyy |
2024-06-15T00:00:00 |
15-Jun-2024 01:45 PM |
dd-MMM-yyyy hh:mm a |
2024-06-15T13:45:00 |
2024-06-15T13:45:30 |
yyyy-MM-dd'T'HH:mm:ss |
2024-06-15T13:45:30 |
Tip: Literal characters in the pattern (such as the
Tseparator in ISO 8601 format) should be wrapped in single quotes — e.g.yyyy-MM-dd'T'HH:mm:ss— to prevent them from being interpreted as pattern tokens.
Typical Use Case
Converting an EDI date field for downstream processing
EDI documents commonly carry dates in compact formats without separators — for example, an 850 Purchase Order might express a required delivery date as 20240615 in a DTM segment. Before this value can be used in a duration calculation or comparison, it needs to be a proper DateTime.
| Property | Value |
|---|---|
| DateTimeString | 20240615 |
| FormatPattern | yyyyMMdd |
| Result | 2024-06-15T00:00:00 |
From there, the DateTime can be passed to CalculateDuration to determine how many days remain until the delivery date, or to CreateStringFromDateTime to reformat it for a different target system.
Notes
- If either
DateTimeStringorFormatPatternis null, the action returns null — include a null check in your ruleset if the source value may be absent. - If the string does not match the pattern exactly, the action will throw a parse error. Ensure the pattern matches the source format precisely, including any separators (dashes, slashes, spaces).
- The returned DateTime includes timezone offset information based on the system's default locale, as shown in the example return value
2016-05-31T11:22:10.000-04:00.
Related Actions
- CreateDateTime: use when date components arrive as separate numeric fields rather than a single string.
- CreateDateTimeFromMilliseconds: use when the source system provides a Unix epoch timestamp.
- FormatDateTime: use to reformat an existing DateTime into a different string pattern for output.
- CreateStringFromDateTime: converts a DateTime back into a formatted string for use in a target document.
Comments
0 comments
Please sign in to leave a comment.