3

I have an Input XML in which I have an time-stamp in long digit. I am trying to convert it into readable date format. I searched on internet and found few solutions. But none of them is working. Please guide me , what am I missing?.

I want to convert this long time-stamp (milliseconds to readable date format).

Input XML:

<Order>
<value>1467702989532</value>
</Order>

XSLT:

<?xml version="1.0"?>
<xsl:stylesheet  xmlns="http://www.w3.org/TR/xhtml1/strict" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"  version="2.0">
<xsl:output method ="xml" indent="yes"/>
<xsl:template match="/Order">

      <NewOrder>
          <dateValue>
            <xsl:value-of select='xs:dateTime("1970-01-01T00:00:00") + value * xs:dayTimeDuration("PT0.001S")'/>
           </dateValue>
      </NewOrder>
</xsl:template>
</xsl:stylesheet>

Current Output:

<?xml version="1.0" encoding="UTF-8"?>
<NewOrder xmlns="http://www.w3.org/TR/xhtml1/strict" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <dateValue />
</NewOrder>
omer khalid
  • 855
  • 1
  • 12
  • 39
  • Works for me under Oxygen/XML 14 (Saxon-EE 9.4.0.6). I get `2016-07-05T07:16:29.532` – Jim Garrison Jul 06 '16 at 06:28
  • What processor are you actually using to perform the transformation? Even though your stylesheet is marked version 2.0, you will need an XSLT 2.0 compliant processor to handle the transformation. – Tim C Jul 06 '16 at 07:43
  • XSLT 1.0: https://stackoverflow.com/a/27993455/3016153 – michael.hor257k Feb 19 '19 at 07:03

0 Answers0