Show TOC

Background documentationXSLDateFormatter Locate this document in the navigation structure

 

The XSLDateFormatter is an extension to the XSL standard. It converts date and time into a defined output format.

XSLDateFormatter class name:

com.sap.portal.httpconnectivity.transformationservice.xslextensions.XSLDateFormatter.

The class has following method:

public static String formatDate(String date, String format)

It formats the specified date according to the specified parameter. The date format follow the specifications of class java.text.SimpleDateFormat that can be found in JDK documentation. The specified date must have one of the following formats:

  • "EEE, dd MMM yyyy kk:mm:ss z"

    Example: Wed, 03 Dec 2003 07:10:05 GMT

  • "yyyy-MM-dd'T'kk:mm-ss:SS"

    Example: 2004-02-03T20:53-08:00

  • "yyyy-MM-dd'T'kk:mm:ss"

    Example: 2004-01-12T01:37:54-400

Example

This example is taken from the RSS_TO_HTMLB transformer and is used to normalize the date formats.

Syntax Syntax

  1. <?xml version="1.0"?>    
    <xsl:stylesheet  
      version="1.0" ... 
      xmlns:transDate="com.sap.portal.httpconnectivity.transformationservice.
                       xslextensions.XSLDateFormatter"
     > 
    … 
     <xsl:template match="*" mode="EPRSS:Date"> 
      <xsl:variable name="DateStr"><xsl:value-of select="."/></xsl:variable> 
      <xsl:value-of name="formatted"
                 select="transDate:formatDate($DateStr,$TimeFormat)"/> 
     </xsl:template> 
    …
    
End of the code.