« December 2006 | Main | February 2007 »

January 2007 Archives

January 22, 2007

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>

XSL date time conversion templates

Evey have to convert between Sieble datetime format and xsd:dateTime format?  Of course you do.  I added the templates that I use for this for your reference.  Enjoy.

About January 2007

This page contains all entries posted to Richard Naszcyniec's Blog in January 2007. They are listed from oldest to newest.

December 2006 is the previous archive.

February 2007 is the next archive.

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

Powered by
Movable Type and Oracle