This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Display current date/time in xsl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Display current date/time in xsl" Watch "Display current date/time in xsl" New topic
Author

Display current date/time in xsl

JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303
I have an xml document which uses xsl for transformation to excel.

in the xsl document, i need to also write code to display the current date/time in the format - {$DD-Mmm-YYYY 24HH:MN:SS TZN}" timestamp unwrapped. TZN is user's time zone.

I actually get the idea to use xs:datetime, however, i am unfamiliar with the usage in xsl. Could someone please help me with the syntax?


SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

There isn't any function in XSLT 1.0 to produce the current timestamp.
Dmitrij Beloborodov
Greenhorn

Joined: Mar 09, 2010
Posts: 2
For XSLT 2.0 you have a wealth of date functions, i.e.:



as well as current-date() and current-time().

For XSLT 1 you'll have to use the dates-and-times EXSLT extension package. Here's a usage example for XSLT 1:



The only problem is get date in specific format.
Dmitrij Beloborodov
Greenhorn

Joined: Mar 09, 2010
Posts: 2
This solution worked out for me. It might help you:

smee bond
Ranch Hand

Joined: Sep 29, 2007
Posts: 34
Thanks for posting the solution Dmitrij Beloborodov. It helped me resolve my problem too!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display current date/time in xsl