One Star

tSetGlobalVar var type

Hi,
Im trying to set a GlobalVar to a value like "99999999999999", but i got the following error: Exception in thread "main" java.lang.Error: Unresolved compilation problem: The literal 99999999999999 of type int is out of range.
How can I set this variable type to "Long"?
5 REPLIES
One Star

Re: tSetGlobalVar var type

Hello,
if that do no problem put " on the value "99999999999999" and use them as string.
After cast the global variable.
Else use a tJava with (Integer)globalMap.put("myKey","value")
else change type to float

Best regards
Jeremie
One Star

Re: tSetGlobalVar var type

Thanks jeremie, but now I got the following error: Exception in component tMap_4. java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long.
In truth I want to use the time of today in this variable, to compare with some files time... any other ideas?
One Star

Re: tSetGlobalVar var type

Ok,
i think you compare two objects with diferent type or the type output is diferent of the type of the expression.
to cast use expression like Long.valueOf(row.RefFieldEnter).
Jeremie
One Star

Re: tSetGlobalVar var type

Thanks,
I already managed to do it by using a TalendDate.GetCurrentDate.GetTime. It seens like this expression returns a long, the variable is automatically set to this type.
One Star

Re: tSetGlobalVar var type

Hello,
if that do no problem put " on the value "99999999999999" and use them as string.
After cast the global variable.
Else use a tJava with (Integer)globalMap.put("myKey","value")
else change type to float
Best regards
Jeremie

Seriously?!
Can't the tSetGlobalVar set long variables?
I have a similar problem where I want to put a long value, which I fetch through a query, into a global var with tSetGlobalVar.
Do I then need to write this in as code in tJava-component?