« .NET/C# for web service test clients? | Main | XSL date time conversion templates »

Converting dates between Siebel and ISO8601 (xsd:dateTime)

These are the code snippets I use in the JDeveloper XSL editor when I
need to exchange dates between Siebel and external systems.  The
external systems specify dates elements in the XSD with using
xsd:dateTime format.  This means dates must be in an ISO8601 format
which Siebel does not provide.  The following snippets are functional
but could benefit from some more robust coding.

Converting Siebel date to ISO8601 format:

<xsl:template name="seblDate2ISO8601">
    <xsl:param name="seblDate"/>
    <xsl:if test="string-length($seblDate) >= 10">
      <xsl:variable name="seblMonth" select="substring($seblDate,1,2)"/>
      <xsl:variable name="seblDay" select="substring($seblDate,4,2)"/>
      <xsl:variable name="seblYear" select="substring($seblDate,7,4)"/>
      <xsl:value-of select="$seblYear"/>
      <xsl:text disable-output-escaping="no">-</xsl:text>
      <xsl:value-of select="$seblMonth"/>
      <xsl:text disable-output-escaping="no">-</xsl:text>
      <xsl:value-of select="$seblDay"/>
    </xsl:if>
    <xsl:if test="string-length($seblDate) = 10">
      <xsl:text disable-output-escaping="no">T000:00:00-05:00</xsl:text>
    </xsl:if>
    <xsl:if test="string-length($seblDate) >= 19">
        <xsl:variable name="seblTime" select="substring($seblDate,12,8)"/>
      <xsl:text disable-output-escaping="no">T</xsl:text>
      <xsl:value-of select="$seblTime"/>
      <xsl:text disable-output-escaping="no">-05:00</xsl:text>
    </xsl:if>
</xsl:template>


The following is used to convert from ISO8601 to Siebel format:

<xsl:template name="ISO8601Date2seblDate">
    <xsl:param name="isoDate"/>
    <xsl:if test="string-length($isoDate) >= 10">
        <xsl:variable name="isoMonth" select="substring($isoDate,6,2)"/>
        <xsl:variable name="isoDay" select="substring($isoDate,9,2)"/>
        <xsl:variable name="isoYear" select="substring($isoDate,1,4)"/>
        <xsl:value-of select="$isoMonth"/>
        <xsl:text disable-output-escaping="no">/</xsl:text>
        <xsl:value-of select="$isoDay"/>
        <xsl:text disable-output-escaping="no">/</xsl:text>
        <xsl:value-of select="$isoYear"/>
    </xsl:if>
    <xsl:if test="string-length($isoDate) >= 19">
        <xsl:variable name="isoTime" select="substring($isoDate,12,8)"/>
        <xsl:text disable-output-escaping="no"> </xsl:text>
        <xsl:value-of select="$isoTime"/>
    </xsl:if>
</xsl:template>

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on January 22, 2007 10:14 AM.

The previous post in this blog was .NET/C# for web service test clients?.

The next post in this blog is XSL date time conversion templates.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle