[resolved] tSetGlobalVar to date

Four Stars

[resolved] tSetGlobalVar to date

Hello,
I have a problem that I really don't understand.
Here is my job:
The first subjob works well.
tMap_1 is:

In the second subjob, there is a tmap (tmap_2): I have a problem with it.
I map my different fields between the fileinput and the database TEMP, and for one row, I map with a var from tSetGlobalVar_1.
Here is the important part of my tMap_2:
myDate is from tSetGlobalVar.
When I run the job, I have this error:Type mismatch, cannot convert from Object to Date.
If I replace by globalMap.get("myDate"), I have Exception in component tMap_2
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date.

Any ideas?
Thanks!

Accepted Solutions
Four Stars

Re: [resolved] tSetGlobalVar to date

Hello,
Thanks for your answer!
What you said helped me to think and I finally solved my problem.
First, I had a mistake in my tSetGlobalVar: the value was incorrect.
Then, I "putted evertything in string": in my fisrt tmap, I set my date value as a string.
Finally, in my last tMap, in put globalMap.get("myDate").toString(), so as a string. My MySQL DB receive the date as a string but knows how to deal with it and put it finally as a date.
And it's ok!

All Replies
Employee

Re: [resolved] tSetGlobalVar to date

What data type is your globalvariable set to? In your first tMap you are going from a Date type to a Date type. In the second the globalvariable is being pulled in as an object and when you replace it as a string. It should be the same as in normal java of converting/casting between data types.
Four Stars

Re: [resolved] tSetGlobalVar to date

Hello,
Thanks for your answer!
What you said helped me to think and I finally solved my problem.
First, I had a mistake in my tSetGlobalVar: the value was incorrect.
Then, I "putted evertything in string": in my fisrt tmap, I set my date value as a string.
Finally, in my last tMap, in put globalMap.get("myDate").toString(), so as a string. My MySQL DB receive the date as a string but knows how to deal with it and put it finally as a date.
And it's ok!
Employee

Re: [resolved] tSetGlobalVar to date

Glad it helped! Smiley Happy