File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply 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: 16482
    
    2

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Display current date/time in xsl
 
Similar Threads
How to get todays/current date in XSL
Get current week date
How to get Current Date in Xsl
how can i access protected methods?
Get current week date