Project

Profile

Help

exception calling java function

Added by Anonymous almost 17 years ago

Legacy ID: #4327016 Legacy Poster: Igor Karp (ikarp)

Hello All, I am trying to use Java extension function to convert timestamps to local timezone. I am having trouble passing parameter of the type long to java.util.TimeZone getOffset method, but what is strange that the same value can be passed as a long to java.util.Date constructor. The minimal example is below: xml: <?xml version="1.0"?> <root> <start_utc>2007-05-24T11:11:11Z</start_utc> </root> xslt: <?xml version="1.0" encoding="UTF-8"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0" exclude-result-prefixes="xs"> <xsl:output method="xml" indent="yes"/> <xsl:variable name="tz"> <xsl:value-of xmlns:tz="java:java.util.TimeZone" select="tz:get-time-zone('Europe/Berlin')"/> </xsl:variable> <xsl:template match="start_utc"> <xsl:variable name="start_unix" as="xs:long"> <xsl:value-of select="((. cast as xs:dateTime - '1970-01-01T00:00:00Z' cast as xs:dateTime) div 'PT0.001S' cast as xs:dayTimeDuration) cast as xs:long"/> </xsl:variable> <testt> <xsl:value-of xmlns:tz="java:java.util.TimeZone" select="tz:get-offset($tz, $start_unix)"/> </testt> <testd> <xsl:value-of xmlns:d="java:java.util.Date" select="d:new($start_unix)"/> </testd> </xsl:template> </xsl:transform> the error i get is: SXJE0021: Error in call to extension function {public int java.util.TimeZone.getOffset(long)}: Cannot convert supplied XPath value to the required type for the extension function I have a workaround but I would really like to get some ideas how to fix this. Regards, Igor


Please register to reply