sandunes90
sandunes90

Reputation: 473

XSLT 1.0 - how to convert string to TIME format?

In my incoming XML I get an input string like -

50000000

I want to convert it using an XSLT into the following format -

50:00:00.00

How can I achieve it using XSLT? I do not know of any inbuilt functions/templates that can convert it into this format.

Upvotes: 1

Views: 458

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 117175

This will work for your example, as well as for any other string that contains exactly 8 digits:

<xsl:value-of select="substring($string, 1, 2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring($string, 3, 2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring($string, 5, 2)"/>
<xsl:text>.</xsl:text>
<xsl:value-of select="substring($string, 7, 2)"/>

Upvotes: 1

Related Questions