Subject: [xsl] Calling mutator java method (date fields to seconds-since-epoch with java.util.GregorianCalendar) From: "Tim Lebo" <timleboxslt@xxxxxxxxx> Date: Mon, 21 Aug 2006 21:34:56 -0400 |
I need to determine the number of seconds past the epoch given the year, month, day, hour, and minute fields (as strings).
This can be done with the java.util.GregorianCalendar class using the set(year,month,day,hour,minute) mutator and calling the getTimeInMillis() accessor. I have been able to demonstrate this in a sample main class that uses GregorianCalendar:
// For year,month,day,hour,min -> seconds since epoch import java.util.Calendar; import java.util.GregorianCalendar;
public static void main(String args[]) { Calendar myCal = new GregorianCalendar(); myCal.set(2006,7,21,13,26,0); //1156181207 System.out.println(myCal.getTimeInMillis()/1000 - 1156181207); }
The following xslt shows how I instantiate a GregorianCalendar. Two outputs are obtained: 1) A failed attempt to get the seconds-since-the-epoch after the set method call 2) The objects toString, which shows that the date information is actually the time of execution and not the date set
This leads me to believe that the mutator call did not 'take effect'. Looking to previous java-interaction solutions that I have created, I notice that this is the first time I am calling an object's mutator method, which returns void. Does this need to be handled differently?
Regards, Tim
xmlns:cal="java:java.util.GregorianCalendar" exclude-result-prefixes="xfm xs">
xs:integer('13'),xs:integer('26'),xs:integer('0'))"/>
<xsl:value-of select="concat('expecting seconds-since-epoch of 2006 21 Aug at 13:26:00, but getting current seconds-since-epoch: ',$NL,
xs:integer(cal:getTimeInMillis($start)) div xs:integer('1000'),$NL,$NL)"/>
<xsl:value-of select="concat('toString indicates that the call to set the date was not recognized (See DAY_OF_MONTH,HOUR_OF_DAY...):',$NL,
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Transform xml without cop, Michael Kay | Thread | RE: [xsl] Calling mutator java meth, Michael Kay |
Re: [xsl] Transform xml without cop, David Carlisle | Date | [xsl] recursive template call, howt, Sam Carleton |
Month |