cancel
Showing results for 
Search instead for 
Did you mean: 

How use XSLT mapping to format date

huibin_lau
Participant
0 Kudos

Hi Integration Experts,

I need to convert a date in this format

2018-04-13T12:42:42.224416+00:00 to ddMMyyHHmmss based on the substrings of the original date value by using XSLT mapping. How I can achieve this?

Input:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<order>
<id>123</id>
<create_date>2018-01-01T12:00:00.224416+00:00</create_date>
</order>
</root>

output:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<order>
<id>123</id>
<create_date>20180101120000</create_date>
</order>
</root>

Have a nice weekend!

Regards,

Jeremy

Accepted Solutions (1)

Accepted Solutions (1)

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Jeremy,

Below will convert the same.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="@* | node()">
		<xsl:copy>
			<xsl:apply-templates select="@* | node()"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="create_date">
		<create_date>
			<xsl:value-of select="format-dateTime(.,'[Y0001][M01][D01][H01][m01][s01]')" />
		</create_date>
	</xsl:template>

</xsl:stylesheet>

Regards,

Sriprasad Shivaram Bhat

Answers (1)

Answers (1)

huibin_lau
Participant
0 Kudos

Hello Sriprasad Shivaram Bhat,

Thanks this works!

Regards,

Jeremy