我的 UI 以毫秒为单位将用户选择的日期提供给后端休息层。
例如,假设用户从 UI 中选择“07/11/2018”,然后它以毫秒“1541509200000”传递到 REST 层。REST 层将此值映射到我的 DTO 中的“XMLGregorianCalendarObject”。
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;
}
}
这个 DTO 被转换为 XML 并被存储。XML 有效负载如下所示:
<personDetails>
<dateOfBirth>2018-11-06Z</dateOfBirth>
</personDetails>
我有下面的 XSLT 代码,目前只显示上面的 dateOfBirth 元素:
<?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>
它生成输出
Date of birth: 2018-11-06Z
我应该怎么做才能将 dateOfBirth 显示为原始用户在 XSLT 转换中选择 07/11/2018 。