My UI supplies the user selected date in milliseconds to the backend rest layer.
For e.g Say the user selects "07/11/2018" from the UI then it gets passed on to the REST layer as milliseconds '1541509200000'. And the REST layer maps this value to a 'XMLGregorianCalendarObject' within my DTO.
import java.io.Serializable;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.bind.annotation.XmlSchemaType;
public class PersonDetails implements Serializable
{
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar dateOfBirth;
public XMLGregorianCalendar getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(XMLGregorianCalendar value) {
this.dateOfBirth = value;
}
}
And this DTO gets converted to an XML and stored. The XML payload looks like below :
<personDetails>
<dateOfBirth>2018-11-06Z</dateOfBirth>
</personDetails>
I have the below XSLT code which is currently just displaying the above dateOfBirth element :
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<div>
<div> Date of birth: </div>
<div> <xsl:value-of select="//personDetails/dateOfBirth" /> </div>
</div>
</xsl:template>
And it generates the output
Date of birth: 2018-11-06Z
What should i do to display the dateOfBirth as the original user selected 07/11/2018 in the XSLT transformation .
XSLT 1.0 has no concept of dates. You must manipulate the input using string functions: