2 Replies Latest reply on Jan 17, 2018 4:31 PM by sebastienl RSS
    sebastienl Explorer

    Rhino version



    I'm trying to parse an ISO String date with a time zone in a JS service (2016-03-23T17:38:01.045+0100) and it looks like the JS engine is not able to handle it. When I try to print the date in logs I get this error : Invalid Date.


    I tried the same code directly in Rhino console from the jar delivered in Thingworx and I get the same issue (sound logic, but it was just to be sure) :


    D:\Applications\apache-tomcat-8.0.29\webapps\Thingworx\WEB-INF\lib>java -jar custom-rhino-js-5.1.0.jar
    Rhino 1.7 release 5 PRERELEASE 2013 10 14
    js> var t = new Date("2016-03-23T17:38:01.045+0100");
    js> t
    Invalid Date


    Then I tried the same code in the last version of Rhino and it work perfectly :


    D:\tmp>java -jar rhino-
    Rhino 2016 02 03
    js> var t = new Date("2016-03-23T17:38:01.045+0100");
    js> t
    Wed Mar 23 2016 17:38:01 GMT+0100 (CET)


    So my question is : Is there a way to upgrade Rhino engine embedded in Thingworx to the last version ?


    Thanks a lot,



      • Re: Rhino version
        carlesc Heavyweight Champ

        Hi Sébastien,


        What you are trying to accomplish? I mean, Javascript used on server side, doesn't use Standard Date objects, they map it to Java Joda Time library, then still if you compile it with the latest Rhino it "won't work".


        If you want to parse dates with Offsets you can use parseDateISO script function that they provide on code snippets, if you want to do real TimeZone Date operations, then you are out of luck with Standard TW features. You will need to build a custom extension in Java to provide this features to Server Side Javascript, I already had done one, it's not a hard work, as the required Joda Time libraries are embedded with the platform.



          • Re: Rhino version
            sebastienl Explorer

            Hi Carles,


            Thanks a lot for your answer, parseDateISO is what I was looking for ! I'm wondering why I didn't search this in snippets myself....

            Nice to see that we can have quick help on the forum !