Reputation: 1498
Hoping that someone else out there uses Altova Mapforce for formatting dates.
I am trying to convert the date format of my XML file. My XML file has a tag with different values like:
<submitTime>2016-06-09T18:27:56+0000</submitTime>
<submitTime>2016-06-09T18:13:10+0000</submitTime>
I am using an XSLT stylesheet to convert the date format into form (YYYY-MM-DD)
<submitTime>2016-06-09</submitTime>
This is my XSLT which I have coded using Altavo Mapforce software.
.......
<submitTime>
<xsl:sequence select="format-date(xs:date(fn:string(_source/submitTime)), '[y,4-4][M,2-2][D,2-2]', 'en', (), ())"/>
</submitTime>
.......
But when I ran this XSLT with XML using a java program, I am getting this error:
FORG0001: Invalid date "2016-06-09T17:38:20+0000" (Value includes time)
I am very new to this. I might be missing something. Is there any other way in Altova to convert the date into this format (YYYY-MM-DD). Any help would be appreciated.
Upvotes: 1
Views: 1935
Reputation: 399
First you need to parse it into a MapForce valid Date or DateTime with the function parse-date or parse-dateTime then you can use format-date or format-dateTime.
If you don't parse first, MapForce will implicitly parse it and that can fail.
Upvotes: 1
Reputation: 116959
Why don't you simply do:
<xsl:value-of select="substring-before(submitTime, 'T')"/>
You will never be able to format the input using the format-date()
function, because it's not a date, nor the format-dateTime()
function, because it's not a valid dateTime either (the time offset needs to be in hh:mm
format).
Upvotes: 1