Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Create singleton object

  1. #1
    Join Date
    Jun 2010
    Posts
    114

    Lightbulb Create singleton object

    Hi,

    Every time, I run the transformation, I want to assign the current date to a variable. But, I don't want to create a date object for each row. I have a work around but, I think there could be a better way to do this.

    For now, I am using a count variable in "Sequence step" and then, I am using "JavaScript" step to create Date object only once by comparing the generated sequence number against 1 as follows:


    if
    (count == 1)

    {
    var


    today = new java.util.Date();
    }

    There could be other options which I might be missing. Is there a better way where you could create an object only once and assign as a constant or something like that?


    Thanks,
    Om
    Attached Images Attached Images  

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

    Default

    Code:
    var today;
    if (today == null) {
      today = new java.util.Date();
    }
    
    ...
    Good luck.

  3. #3
    Join Date
    Jun 2010
    Posts
    114

    Default

    As simple as that...awesome
    Thanks,
    Om

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.