AnsweredAssumed Answered

Errors trying to convert to unix time with Groovy custom script

Question asked by anne.boonjarern062686 on Oct 10, 2016
Latest reply on Oct 11, 2016 by Srinivas Chandrakanth Vangari

I have a few versions of code that work in a groovy web console, but are throwing errors when I run in Test mode.This code is in a Map function

 

import java.text.*//.* needed for console
import java.util.*;  //.* needed for console

 

def timeS = "20161009_230001"
Date d1 = new SimpleDateFormat("yyyyMMdd_HHmmss").parse(timeS);
unixtime = d1.getTime();

This one is throwing error:

Test execution of Export_Request_Channel completed with errors. Embedded message: [Function: Convert DateTime to Epoch, Scripting (Step 1)]: Error executing custom script: startup failed, Script213.groovy: 7: unexpected token: ? @ line 7, column 1. 1 error (in groovy script); Caused by: startup failed, Script213.groovy: 7: unexpected token: ? @ line 7, column 1. 1 error (in groovy script); Caused by: startup failed, Script213.groovy: 7: unexpected token: ? @ line 7, column 1. 1 error

If I remove the blank line at the end of the code, the error points to line 6, column 25. 

 

In the end, I intend to use a Process Property as the input, but testing with hardcoding the timeS value to try to reduce the errors. (When I was passing timeS as an input variable, I was getting error saying unable to parse datetime)

 

OR, is there an easier way to do this? I have a date time value that needs to be converted to unix time. The value that needs to be converted is stored in a Process Property, and I need the unix time value to also be store in a Process Property to be used as a parameter for an API call. I was trying to follow this approach How to manipulate properties without a Map shape 

Attachments

Outcomes