dateTool in context sensitive velocity reports

Jeff Abbott
Jeff Abbott Member, Data Exchange Posts: 31

I am unable to get the $dateTool to work. I have a date field (revision_date) that I retrieve as $revDate. This then produces values like:

09/08/2022 04:00:00 AM UTC

However, I'm not able to use the dateTool to format the output.  The velocity report always returns the script text itself, for example:
<p>$dateTool.format('MMM d, yyyy', $revDate)</p>
Returns 
$dateTool.format('MMM d, yyyy', $revDate)

Also, any call to $revDate.convertStringToDate() fails.



------------------------------
Jeff Abbott
Leidos
Orlando FL
------------------------------

Comments

  • [Deleted User]
    [Deleted User] Posts: 152
    edited February 2023
    Hi Jeff, 

    So that we can take a deeper look into this, can you open a 
    Support ticket and reference this thread in the ticket description (as well as your version/type of Jama and any other pertinent info) on it, please

    Thank you!

    ------------------------------
    Carly Rossi // she/her
    Community Manager // Jama Software
    Portland, OR
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 02-07-2023 11:37
    From: Jeff Abbott
    Subject: dateTool in context sensitive velocity reports

    I am unable to get the $dateTool to work. I have a date field (revision_date) that I retrieve as $revDate. This then produces values like:

    09/08/2022 04:00:00 AM UTC

    However, I'm not able to use the dateTool to format the output.  The velocity report always returns the script text itself, for example:
    <p>$dateTool.format('MMM d, yyyy', $revDate)</p>
    Returns 
    $dateTool.format('MMM d, yyyy', $revDate)

    Also, any call to $revDate.convertStringToDate() fails.


    ------------------------------
    Jeff Abbott
    Leidos
    Orlando FL
    ------------------------------
  • Patrick Szabo
    Patrick Szabo Member, Medical Devices & Life Sciences Solution Posts: 55
    edited February 2023
    I use a similar syntax as below in one of our templates and it works fine:
    #set( $rdate = $dateTool.toDate('dd/MM/yyyy hh:mm:ss a z', $revDate))
    #set( $revDate = $dateTool.format('MMM d, yyyy', $rdate))
    <p>$!revDate</p>
    ------------------------------
    Patrick
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 02-07-2023 11:37
    From: Jeff Abbott
    Subject: dateTool in context sensitive velocity reports

    I am unable to get the $dateTool to work. I have a date field (revision_date) that I retrieve as $revDate. This then produces values like:

    09/08/2022 04:00:00 AM UTC

    However, I'm not able to use the dateTool to format the output.  The velocity report always returns the script text itself, for example:
    <p>$dateTool.format('MMM d, yyyy', $revDate)</p>
    Returns 
    $dateTool.format('MMM d, yyyy', $revDate)

    Also, any call to $revDate.convertStringToDate() fails.


    ------------------------------
    Jeff Abbott
    Leidos
    Orlando FL
    ------------------------------
    Patrick
  • Peter Lampacher
    Peter Lampacher Member, Jama Connect Interchange™ (JCI), Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 14
    edited February 2023
    Hi Jeff!

    I am using $dateTool.format('medium_date',$revDate,$reportLocale,$reportTimeZone)

    Be careful with timestamps as they are UTC in the database. This is why you shold pass a $reportTimeZone parameter. Example:

    #set($reportTimeZone=$dateTool.getTimeZone().getTimeZone("Europe/Vienna"))
    #set($reportLocale=$dateTool.getLocale())

    You can find all possible values for TimeZone here:
    What are the Java TimeZone IDs? | Gary Gregory (wordpress.com)

    I learned it the hard way...

    Regards,



    ------------------------------
    Peter Lampacher
    MED-EL
    Innsbruck
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 02-07-2023 11:37
    From: Jeff Abbott
    Subject: dateTool in context sensitive velocity reports

    I am unable to get the $dateTool to work. I have a date field (revision_date) that I retrieve as $revDate. This then produces values like:

    09/08/2022 04:00:00 AM UTC

    However, I'm not able to use the dateTool to format the output.  The velocity report always returns the script text itself, for example:
    <p>$dateTool.format('MMM d, yyyy', $revDate)</p>
    Returns 
    $dateTool.format('MMM d, yyyy', $revDate)

    Also, any call to $revDate.convertStringToDate() fails.


    ------------------------------
    Jeff Abbott
    Leidos
    Orlando FL
    ------------------------------
  • Alessandro Valli
    Alessandro Valli Member, Data Exchange, Jama Connect Interchange™ (JCI) Posts: 789
    edited February 2023

    HI all,

    I was already sharing this in the past, maybe it is helpful.
    I normally use this :

    $dateTool.format("yyyy-MM-dd'T'HH:mm:ss", $dateTool, $dateTool.getLocale().forLanguageTag("de"), $dateTool.getTimeZone().getTimeZone("CET"))
    The only issue is the hard-coded time zone

    Best,


    ------------------------------
    Alessandro
    Systems Engineer
    SICK AG
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 02-07-2023 11:37
    From: Jeff Abbott
    Subject: dateTool in context sensitive velocity reports

    I am unable to get the $dateTool to work. I have a date field (revision_date) that I retrieve as $revDate. This then produces values like:

    09/08/2022 04:00:00 AM UTC

    However, I'm not able to use the dateTool to format the output.  The velocity report always returns the script text itself, for example:
    <p>$dateTool.format('MMM d, yyyy', $revDate)</p>
    Returns 
    $dateTool.format('MMM d, yyyy', $revDate)

    Also, any call to $revDate.convertStringToDate() fails.


    ------------------------------
    Jeff Abbott
    Leidos
    Orlando FL
    ------------------------------
    Alessandro
    Systems Engineer
    SICK AG
  • Jeff Abbott
    Jeff Abbott Member, Data Exchange Posts: 31
    edited February 2023
    Thanks Patrick, that did the trick.

    ------------------------------
    Jeff Abbott
    Leidos
    Orlando FL
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 02-07-2023 23:07
    From: Patrick Szabo
    Subject: dateTool in context sensitive velocity reports

    I use a similar syntax as below in one of our templates and it works fine:
    #set( $rdate = $dateTool.toDate('dd/MM/yyyy hh:mm:ss a z', $revDate))#set( $revDate = $dateTool.format('MMM d, yyyy', $rdate))<p>$!revDate</p>
    ------------------------------
    Patrick
    ------------------------------

    Original Message:
    Sent: 02-07-2023 11:37
    From: Jeff Abbott
    Subject: dateTool in context sensitive velocity reports

    I am unable to get the $dateTool to work. I have a date field (revision_date) that I retrieve as $revDate. This then produces values like:

    09/08/2022 04:00:00 AM UTC

    However, I'm not able to use the dateTool to format the output.  The velocity report always returns the script text itself, for example:
    <p>$dateTool.format('MMM d, yyyy', $revDate)</p>
    Returns 
    $dateTool.format('MMM d, yyyy', $revDate)

    Also, any call to $revDate.convertStringToDate() fails.


    ------------------------------
    Jeff Abbott
    Leidos
    Orlando FL
    ------------------------------