Forum Discussion

virender_prajap's avatar
virender_prajap
New Contributor III
7 years ago
Solved

BUG OR ERROR : Date UTC Method

Hi All,

I am using Date.UTC() method to generate last month date & using below syntax which seems to be fine.

Date.UTC(Date.now().minusMonths(1).getFullYear(),Date.now().minusMonths(1).getMonth(),0)

And output preview is also fine.

But while I am inserting data into Orcale DB, 1 day is getting subtracted from the date.

Not able to figure out where is the issue. Tried by changing date data type to varchar2 at DB level…but the value remain same.

  • @virender.prajapati I have seen this happening to me in MySQL. I used toLocalDateTimeString() function before inserting it into the DB and worked fine.

    You can try this in your mapper,
    Date.UTC(Date.now().minusMonths(1).getFullYear(),Date.now().minusMonths(1).getMonth(),0).toLocaleDateTimeString({“format”: “yyyy-MM-dd HH:mm:ss”,“timeZone”:“UTC”})

    You can also look into oracle jdbc url properties

6 Replies

  • cjhoward18's avatar
    cjhoward18
    Employee

    Actually, our Expression Language is not built on top of Nashorn at all. You may have been reading a post about the script snap using a Javascript setting, which is not involved with the expression language.

    The Expression Language is a completely custom-built language that actually gets compiled into Java Byte code to be executed on the JCC.

    • Tim's avatar
      Tim
      New Contributor

      That is good information. I would prefer to write expressions and expression libs than script snaps.

      I do wish there was a way to test them from Javascript or Java in a local editor. Something to consider. Probably a lot of work when many of your users may not use a lot of local coding practices?

      • cjhoward18's avatar
        cjhoward18
        Employee

        Yes, that is very valid. I think making the expression builder more IDE like would be very helpful for developing expressions as well as debugging and testing them.

        For now, a pipeline that validates expression libraries is the best I can think of.