Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: How to add a JavaScript library to Pentaho (For modified JS step)

  1. #1
    Join Date
    Sep 2014
    Posts
    175

    Default How to add a JavaScript library to Pentaho (For modified JS step)

    I want to add a javascript library (moment.js for super annoying time zone issues) to Pentaho so I can use its built in functions for timezone conversion.

    What's the best way to do this?

    I feel like dumping it in a JS step in a transformation is counterproductive, but ... any advice?

  2. #2
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    Why? Janino natively supports timezones. You can enter dates/times in one timezone, and it will translate them to display in your local timezone.

  3. #3
    Join Date
    Sep 2014
    Posts
    175

    Default

    You're saying use the Java scripting step? I'm a bit of a novice with Java but I can give it a whirl.

    But please note ... I want to convert UTC time to CST timezone --- NOT the local timezone. Our ETL servers and databases are located in Europe.


    So I don't want (timezone A) ---> (local timezone) .... I want (timezone A) ---> (timezone B).

    It happens to be UTC to CST, but yeah.

  4. #4
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    The example script in the JavaScript step shows how to set the date time with a TimeZone:

    // str2date(var, var, var, var);
    // 1: String - The Variable with the String to convert.
    // 2: String - The Format:
    // 3: String - The Locale Parameter
    // An valid ISO Language Code. (DE = German, EN = English, FR = France, ...)
    // 4: String - The Timezone Parameter.
    // A valid timezone: EST, GMT, ... (if invalid GMT will be selected as default)

    Alert(str2date("22.02.2008 23:23:01","dd.MM.yyyy HH:mm:ss","DE", "EST"));

    Note also that you can run your PDI instance in another TimeZone, but passing parameters to Java in the batch file / shell script that starts PDI (specifically -Duser.timezone= )

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.