Java bindings error
Friday, 14 December 2012 · 4 messages · last reply 15 Dec 2012
RR
Randy reed14 Dec 2012 22:16 #
Hi all,
I switched from 6.8 to 7.5 and I'm generating an error I didn't get in 6.8 when using Java Bindings
There error is :[FORG0006] Invalid call of Java function:
TimeZone.inDaylightTime(java(), java()) It appears that its problem is using the output of one java function in another function.
Is there some new way to do this in 7.5?
Thanks
Randy
The code is:
declare namespace tz = "java:java.util.TimeZone";
declare namespace dt = "java:java.util.Date";
declare namespace df = "java:java.text.DateFormat";
declare namespace cal = "java:java.util.Calendar";
declare namespace sdf = "java:java.text.SimpleDateFormat";
let $odate := xs:long(1345665817)
let $edate := xs:long($odate)*1000
let $fdate := dt:new(xs:long($edate))
let $tmz := tz:getDefault()
let $tbool := tz:inDaylightTime($tmz, $fdate)
return
(
<results>
<jdate>{$fdate}</jdate>
<Timezone>{$tmz}</Timezone>
<Daylight>{$tbool}</Daylight>
</results>
)--
Dr. Randall Reed
Assistant Professor, Dept. of Philosophy and Religion
Appalachian State University
CG
Christian Grün14 Dec 2012 23:20 #
Randy,
thanks for your update. I have further refined the Java mappings; please check out the latest stable snapshot [1].
Since 7.0, many details of our Java bindings have improved, but it’s generally difficult to find a solution that matches all cases. As there’s no lossless mapping available for Java and XQuery data types, we generally tend to recommend the usage of XQuery functions whenever possible. BaseX provides some few additional converter functions for dates that may be helpful to perform some of the tasks that are otherwise only possible via Java [2].
Best,
Christian
[1] http://files.basex.org/releases/latest/
[2] http://docs.basex.org/wiki/Conversion_Module#Dates_and_Durations
Quoted text · Randy reed · 45 lines
On Fri, Dec 14, 2012 at 9:15 PM, Randy reed <randywreed at gmail.com> wrote: > Hi all, > > I switched from 6.8 to 7.5 and I'm generating an error I didn't get in > 6.8 when using Java Bindings > There error is :[FORG0006] Invalid call of Java function: > TimeZone.inDaylightTime(java(), java()) It appears that its problem is > using the output of one java function in another function. > > Is there some new way to do this in 7.5? > Thanks > Randy > > The code is: > > declare namespace tz = "java:java.util.TimeZone"; > declare namespace dt = "java:java.util.Date"; > declare namespace df = "java:java.text.DateFormat"; > declare namespace cal = "java:java.util.Calendar"; > declare namespace sdf = "java:java.text.SimpleDateFormat"; > > > let $odate := xs:long(1345665817) > let $edate := xs:long($odate)*1000 > let $fdate := dt:new(xs:long($edate)) > let $tmz := tz:getDefault() > let $tbool := tz:inDaylightTime($tmz, $fdate) > > return > ( > <results> > <jdate>{$fdate}</jdate> > <Timezone>{$tmz}</Timezone> > <Daylight>{$tbool}</Daylight> > </results> > ) > > -- > Dr. Randall Reed > Assistant Professor, Dept. of Philosophy and Religion > Appalachian State University > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
CG
Quoted text · Randy reed · 3 lines
> […] Its one of the bang-your-head-against-a-wall type > mysteries that seems to have no reason. > Randy
…no idea what might have caused this “fix”; let’s hope it stays that way… After all, it’s an even better choice anyway to switch over to 7.5 ;)
Christian
Quoted text · Randy reed · 74 lines
>> thanks for your update. I have further refined the Java mappings; >> please check out the latest stable snapshot [1]. >> >> Since 7.0, many details of our Java bindings have improved, but it’s >> generally difficult to find a solution that matches all cases. As >> there’s no lossless mapping available for Java and XQuery data types, >> we generally tend to recommend the usage of XQuery functions whenever >> possible. BaseX provides some few additional converter functions for >> dates that may be helpful to perform some of the tasks that are >> otherwise only possible via Java [2]. >> >> Best, >> Christian >> >> [1] http://files.basex.org/releases/latest/ >> [2] http://docs.basex.org/wiki/Conversion_Module#Dates_and_Durations >> ___________________________ >> >> On Fri, Dec 14, 2012 at 9:15 PM, Randy reed <randywreed at gmail.com> wrote: >>> Hi all, >>> >>> I switched from 6.8 to 7.5 and I'm generating an error I didn't get in >>> 6.8 when using Java Bindings >>> There error is :[FORG0006] Invalid call of Java function: >>> TimeZone.inDaylightTime(java(), java()) It appears that its problem is >>> using the output of one java function in another function. >>> >>> Is there some new way to do this in 7.5? >>> Thanks >>> Randy >>> >>> The code is: >>> >>> declare namespace tz = "java:java.util.TimeZone"; >>> declare namespace dt = "java:java.util.Date"; >>> declare namespace df = "java:java.text.DateFormat"; >>> declare namespace cal = "java:java.util.Calendar"; >>> declare namespace sdf = "java:java.text.SimpleDateFormat"; >>> >>> >>> let $odate := xs:long(1345665817) >>> let $edate := xs:long($odate)*1000 >>> let $fdate := dt:new(xs:long($edate)) >>> let $tmz := tz:getDefault() >>> let $tbool := tz:inDaylightTime($tmz, $fdate) >>> >>> return >>> ( >>> <results> >>> <jdate>{$fdate}</jdate> >>> <Timezone>{$tmz}</Timezone> >>> <Daylight>{$tbool}</Daylight> >>> </results> >>> ) >>> >>> -- >>> Dr. Randall Reed >>> Assistant Professor, Dept. of Philosophy and Religion >>> Appalachian State University >>> _______________________________________________ >>> BaseX-Talk mailing list >>> BaseX-Talk at mailman.uni-konstanz.de >>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > > > > -- > Dr. Randall Reed > Assistant Professor, Dept. of Philosophy and Religion > Appalachian State University > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
RR
Thanks Christian. I discovered this in 7.5 because of a weird thing. I couldn't for the life of me get 6.8 to generate the right timezone -- i'm in EST and it kept saying GMT-500 which is at some level correct, but didn't allow me to query whether a given date was in daylight savings time. Through much pain and googling, I found that I need to update the tz data for jre 7, but when I finished I found, even through java classes that I ran separately reported the timezone correctly, when I went through basex, it still gave me the GMT tz not EST. So on a lark I tried it in 7.5 That's when 7.5 gave me the error, so I tried it again in 6.8 just to make sure the syntax was right. To my surprise 6.8 suddenly gave me the right tz. Something about running 7.5 seemed to reset the timezone data in 6.8. Any idea why that happened? Its one of the bang-your-head-against-a-wall type mysteries that seems to have no reason.
Randy
Quoted text · Christian Grün · 67 lines
On Fri, Dec 14, 2012 at 5:20 PM, Christian Grün <christian.gruen at gmail.com> wrote: > Randy, > > thanks for your update. I have further refined the Java mappings; > please check out the latest stable snapshot [1]. > > Since 7.0, many details of our Java bindings have improved, but it’s > generally difficult to find a solution that matches all cases. As > there’s no lossless mapping available for Java and XQuery data types, > we generally tend to recommend the usage of XQuery functions whenever > possible. BaseX provides some few additional converter functions for > dates that may be helpful to perform some of the tasks that are > otherwise only possible via Java [2]. > > Best, > Christian > > [1] http://files.basex.org/releases/latest/ > [2] http://docs.basex.org/wiki/Conversion_Module#Dates_and_Durations > ___________________________ > > On Fri, Dec 14, 2012 at 9:15 PM, Randy reed <randywreed at gmail.com> wrote: >> Hi all, >> >> I switched from 6.8 to 7.5 and I'm generating an error I didn't get in >> 6.8 when using Java Bindings >> There error is :[FORG0006] Invalid call of Java function: >> TimeZone.inDaylightTime(java(), java()) It appears that its problem is >> using the output of one java function in another function. >> >> Is there some new way to do this in 7.5? >> Thanks >> Randy >> >> The code is: >> >> declare namespace tz = "java:java.util.TimeZone"; >> declare namespace dt = "java:java.util.Date"; >> declare namespace df = "java:java.text.DateFormat"; >> declare namespace cal = "java:java.util.Calendar"; >> declare namespace sdf = "java:java.text.SimpleDateFormat"; >> >> >> let $odate := xs:long(1345665817) >> let $edate := xs:long($odate)*1000 >> let $fdate := dt:new(xs:long($edate)) >> let $tmz := tz:getDefault() >> let $tbool := tz:inDaylightTime($tmz, $fdate) >> >> return >> ( >> <results> >> <jdate>{$fdate}</jdate> >> <Timezone>{$tmz}</Timezone> >> <Daylight>{$tbool}</Daylight> >> </results> >> ) >> >> -- >> Dr. Randall Reed >> Assistant Professor, Dept. of Philosophy and Religion >> Appalachian State University >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
--
Dr. Randall Reed
Assistant Professor, Dept. of Philosophy and Religion
Appalachian State University
Written for BaseX 7.3. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery