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: 12871

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:

 
 
subject: Display current date/time in xsl
 
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture