I have the following string:
input.xml
<Request>
<ClientDt>1/6/2016 11:15:25 AM</ClientDt>
<!-- rest of input -->
</Request>
The date section of the string is in M/D/YYYY format. I need to convert it to the format listed in the question title, for example
output.xml
<Request>
<ClientDt>2016-01-06T11:15:25:000000-05:00</ClientDt>
<!-- rest of output -->
</Request>
the -05:00 being UTC i.e. this is eastern time, which is 5 hours behind UTC
I initially tried piping the value through the format-dateTime function with the appropriate parameters set:
stylesheet.xsl
<xsl:template match="ClientDt">
<xsl:value-of select="format-dateTime(., '[Y0001]-[M01]-[D-01]T[H01]:[m01]:[s01]:[f000001]')" />
<!-- Note: yet to figure out timezone part of this -->
</xsl:template>
but got errors stating that the datetime was invalid(Non-numeric year component). To see if it would work otherwise I changed the date portion to 2016-1-6 and kept the time as is, and it throws an error stating the month must be 2 digits.Again, I tweaked the input date to 2016-01-06 and got a similar error, this time stating day must be 2 digits.
Are there any other standard functions that could deal with this format of dateTime, or any in another library? Or would I have to try and piece this together with various pieces of regex, i.e. add in zeroes to month and day if required, switch the parts of the date around manually via concat, etc? I am using Saxon-He version 9.7.0-8