How to properly parse a dateTime string with milliseconds in TIBCO ActiveMatrix BusinessWorks™

When parsing a dateTime string in TIBCO ActiveMatrix BusinessWorks™ make sure to check the presence of milliseconds. However when the milliseconds are precisely ‘000’ like in in the example ‘20150508093620000’, parsing will surprisingly not result in any exceptions.

Situation that will work:
Despite the fact that milliseconds are present (‘000’) this operation will still work without exceptions.

tib:parse-dateTime(‘yyyyMMddHHmmss’,’20150508093620000‘)

Situation that will fail:
When milliseconds are not taken into account and the dateTime contains a value which is not equal to ‘000’ the operation will not work and lead into an exception.

tib:parse-dateTime(‘yyyyMMddHHmmss’,’20150508093620813‘)

Solution:
The addition of ‘SSS‘* in capital letters will make sure to take the milliseconds into account while parsing a dateTime string.

tib:parse-dateTime(‘yyyyMMddHHmmssSSS‘,’20150508093620813‘)

*A String containing a format describing how the date should be formatted. e.g. “yyyy-MM-dd HH:mm:ss”, “EEE, yyyy-MM-dd HH:mm:ss.SSS Z”. SSS (3 S) is required for formating millisecond. i.e. “yyyy-MM-dd HH:mm:ss.SSS” is correct, but “yyyy-MM-dd HH:mm:ss.S” is not valid. (source: docs.tibco.com)

Advertisements

One comment

  1. Reblogged this on anz.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: