Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Method parsedate does not work - "undefined for the type TalendJavaSourceViewer"

In my tMap component I'm trying to compare two dates, using this code in expression editor:

 

TalendDate.compareDate(parseDate("dd-MM-yyyy","01-01-2000"),row1.CREATEDDATE)

I need to compare the date "01-01-2000" to the date incoming from the dbInputTable row1 and, if equals, do something. Since I can't compare string and dates, I thought about parsing the string first to date and then compare, but when I hit "Test" in the expression builder I have this error:

 

the method parsedate is undefined for the type TalendJavaSourceViewer0

What does this mean? Where am I going wrong?

Labels (3)
1 Solution

Accepted Solutions
Jesperrekuh
Specialist
Specialist

My code/example runs, no copy paste errors? you probably checked.
Make sure you checked the var compared as "Null / Nullable" (checkbox in tMap)
It will change from int to Integer.

Your error looks like you missing out on some quotes and cant generate your code...

View solution in original post

17 Replies
Jesperrekuh
Specialist
Specialist

TalendDate.parseDate("dd-MM yyyy","01-01-2000")

Thats it. just add TalendDate.

Anonymous
Not applicable
Author


@Dijke wrote:
TalendDate.parseDate("dd-MM yyyy","01-01-2000")

Thats it. just add TalendDate.


I've already tried it but still doesn't work, gives me a generic error (exception in thread main).

Jesperrekuh
Specialist
Specialist

in the date format between month and year a '-' is missing:
"dd-MM yyyy","01-01-2000" should be : "dd-MM-yyyy","01-01-2000"
Anonymous
Not applicable
Author

Copy-paste error, there is in my code. (I'll modify the post)
Jesperrekuh
Specialist
Specialist

I use something different for comparison.

 

// java.util.Date.before(Date when)
// java.util.Date.after(Date when)
// java.util.Date.compareTo(Date when)

TalendDate.parseDate("dd-MM-yyyy","01-01-2000").compareTo(row1.CREATEDDATE)

 

Sidenote: on the TalendJavaSourceViewer ... is it a supported version of java? 

Anonymous
Not applicable
Author


@Dijke wrote:

I use something different for comparison.

 

// java.util.Date.before(Date when)
// java.util.Date.after(Date when)
// java.util.Date.compareTo(Date when)

TalendDate.parseDate("dd-MM-yyyy","01-01-2000").compareTo(row1.CREATEDDATE)

 

Sidenote: on the TalendJavaSourceViewer ... is it a supported version of java? 


I've tried this way doing this:

TalendDate.parseDate("dd-MM-yyyy","01-01-2000").compareTo(row1.CREATEDDATE) == 0 ? TalendDate.parseDate("dd-MM-yyyy","01-01-1900") : row1.CREATEDDATE

But when hitting "test" the same error appears

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

Is there a way to see what this unresolved compilation problem is?

Jesperrekuh
Specialist
Specialist

Ok, it might seems strange but... did you restart talend? Sometimes some errors result in some sort of crashing talend (which is eclipse) ... and you keep on running into errors without any particular reason...
This might be the case.

if you select the tMap component (do not open, single click, just select) and on the left lower bottom of this panel (next to view) there's a tab/panel named : code ...
Anonymous
Not applicable
Author

I restarted Talend and on the expression builder I have no errors now, but when I try to run the job an error appears saying:

 

object is not an instance of declaring class
Jesperrekuh
Specialist
Specialist

It probably has to do with the TalendDate.parseDate().compareTo() which doesnt inherit some util Date stuff I suppose

Try:
in tMap create a var of type Date prsddate which you parse the date
And use in another created var of type int : compareresult
here you: Var.prsddate.compareTo(row1.CREATEDDATE)