Skip to Content
0

How use XSLT mapping to format date

Apr 14 at 02:36 AM

102

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Sriprasad Shivaram Bhat
Apr 14 at 05:04 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Apr 16 at 02:10 AM
0

Hello Sriprasad Shivaram Bhat,

Thanks this works!

Regards,

Jeremy

Share
10 |10000 characters needed characters left characters exceeded