Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: how to use java in kettle

  1. #1

    Default how to use java in kettle

    Hi,
    I want to add some java code in the script step,but I don't now how to use it.how to use the java class in kettle?:
    //script
    /* the var date is a field get from last step and have two kinds of formats 'dd/MM/yyyy' and 'yyyy-MM-dd' ,I want convert it to 'yyyyMMdd'
    */
    //use the java code like this:

    java;
    var dateFormat=new java.text.SimpleDateFormat("yyyyMMdd");
    var PriceDate =dateFormat.parse(date);

    but there is a erro

    Couldn't execute this script! Error on position (5:0) :
    Wrapped java.text.ParseException: Unparseable date: "test value test value test value test value test value test value test value test value test value test value" (script#5)

  2. #2
    Join Date
    May 2006
    Posts
    4,882

    Default

    You can't test, but you can execute... I belief this was changed in 3.2

    What you see is that in old versions when you pressed the test button "dummy" data was inserted on the input... and if you did need a specific format in your data you were out of luck.

    Regards,
    Sven

  3. #3

    Default

    not just test have erro ,but also the runing .I have questiong about use java in kettle .Should I add the local JDK and JRE lib path to the kettle's path(in the spoon.bat)? If not we can't use the basic object such as java.util.* ,java.text.* in kettle right?

  4. #4
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    Code:
    var dateFormat=new Packages.java.text.SimpleDateFormat("yyyyMMdd");

  5. #5

    Default

    Quote Originally Posted by MattCasters View Post
    Code:
    var dateFormat=new Packages.java.text.SimpleDateFormat("yyyyMMdd");
    I have did by this way and when I run the test script and get avaiables that a erro like this
    "Wrapped java.text.ParseException: Unparseable date: "test value test value"" ,but when I priview it the date format is 'yyyy/MM/dd'
    Before this step I generate a rows and set the default value like 'yyyy-MM-dd'

    BTW,if we have a mixed data format filed,how to do this.

    Thanks,Matt

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.