cancel
Showing results for 
Search instead for 
Did you mean: 

Date Time Conversions with Time Zone

Former Member
0 Kudos

Hi All,

Can you please let me know if we can achieve the below date transformation in graphical mapping or we have to go with UDF - in which case - I might need help on the UDF.

Input Date: 2016-05-11T16:21:12.000-04:00

Output Date: 05/11/2016 16:09:08 MDT

I hoping we can acheive through regular date transformation - however, it failed to recognize - yyyy-MM-dd'T'HH:mm:ss.SSSZ - so I wasnt sure if this is the correct representation of 2016-05-11T16:21:12.000-04:00 ?!

Thank you so much for your timely help in advance!!

Thank you,

Rithvik

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Rithvik

I'm guessing your PI system is not on 7.5 yet, so it is running on Java 6 (if on 7.31 or 7.4) or below.

Java 6 or below does not support the ISO 8601 time zone format in it's SimpleDateFormat class. Refer the following discussion - Converting ISO 8601-compliant String to java.util.Date - Stack Overflow

Your input is in ISO 8601 format (time zone with a colon : character). As such, it is unable to parse it correctly, and it has nothing to do with the T character.

That explains your problem.

However, it is unclear what is your requirement. From your input/output examples: MDT (Mountain Daylight Time) is -06:00 and does not correspond to -04:00.

Do you want to just change the date format and retain the it in the same time zone. Or do you want to change time zones as well?

Either way, I'd suggest you go for Joda Time libraries to assist you in handling the conversion. It will be able to parse ISO 8601 format properly, and change time zones if necessary. You can check out my blog below:-

Regards

Eng Swee

Answers (1)

Answers (1)

Harish
Active Contributor
0 Kudos

Hi Rithvik,

The date translation function does not work with letter T as a separator. you can map it as below