Extracting the timezone from an xs:dateTime : format dateTime « XSLT stylesheet « XML Tutorial

XML Tutorial
1. Introduction
2. Namespace
3. XML Schema
4. XPath
5. XSLT stylesheet
Java
XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
XML Tutorial » XSLT stylesheet » format dateTime 
5. 23. 1. Extracting the timezone from an xs:dateTime
File: Transform.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:text>Extracting the timezone from an xs:dateTime:</xsl:text>
    <xsl:variable name="currentDateTime" as="xs:dateTime" select="current-dateTime()"/>
    
    <xsl:text>The current date and time is: </xsl:text>
    <xsl:value-of select="$currentDateTime"/>

    <xsl:text>The current timezone is: </xsl:text>
    <xsl:value-of select="timezone-from-dateTime($currentDateTime)"/>
    <xsl:text>The timezone is also known as </xsl:text>
    <xsl:value-of select="format-dateTime($currentDateTime, '[ZN]')"/>

  </xsl:template>

</xsl:stylesheet>


Output:

Extracting the timezone from an xs:dateTime:The current date and time is: 2008-12-11T13:11:17.75-08:00The current timezone is: -PT8HThe timezone is also known as -08:00
5. 23. format dateTime
5. 23. 1. Extracting the timezone from an xs:dateTime
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.