Need help working with datetime handler

I’m new to Teneo and would like to compliment the sitemakers on the helpful content. It made it very easy to get started. Now I am trying something with the date time handler described here:

I want to do a horoscope so I ask the user for a birthdate. I am not interested in time, just the date. The example on the above page is geared towards getting a date and time. So I tried to adjust it.

In a listening transition I did this - and it works:

%DT_DATE.PHR^{dateRepresentation =}

After adding interpretation I got errors, so I guess something is wrong with this call.

date = date.Handler.interpret(dateRepresentation)

Warning: 03/19/2020 14:37:14: Flow [Horoscope] (ID=88983f16-f958-481c-a48f-0f38ff2014b7), vertex [Interpret date] (ID=6899e2f8-55f4-4368-b45d-a7adf770ba4e): Script action execution failed at line #1: java.lang.NullPointerException: Cannot invoke method interpret() on null object
javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method interpret() on null object
at ~[?:?]

Thanks in advance for your help.

Hi Ines,

The first of your steps, where you grab the date from the input is (as you said) indeed correct. It is possible to pickup only dates (using %DT_DATE.PHR), only times (%DT_TIME.PHR) or dates and times combined (%DT_DATE_TIME.PHR).

However, when you call the interpreter, you have to use the name of the class to call it, which is datetime regardless of whether you picked a date, a time or both.

So in order to make the call to the interpreter work, you have to add:

date = datetime.Handler.interpret(dateRepresentation)

Hope this solves your problem!



1 Like

I knew it must be something simple. Thanks, Fabienne! That’s sorted it.