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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register 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)
17 Replies
Anonymous
Not applicable
Author

Like this?

Date prsddate = parseDate("dd-MM-yyyy","01-01-2000");
int compareresult = prssdate.compareTo(row1.CREATEDDATE);
compareresult == 0 ?  parseDate("dd-MM-yyyy","01-01-1900") : row1.CREATEDDATE;

The error is still the same

Jesperrekuh
Specialist
Specialist

check screenshot


compareTo.jpg
Anonymous
Not applicable
Author

Thanks. And how can I add the if then else condition?

0683p000009LzP4.png

Jesperrekuh
Specialist
Specialist

Change your Var datatypes, they are still String ... should be Date and int
And the if in the output should be: Var.compared.equals(0)
Anonymous
Not applicable
Author

Did this... is it correct? I need two options for the output

 

0683p000009Lzeh.png

Jesperrekuh
Specialist
Specialist

Try it like this... screenshot

Do you also want output where date are more recent then your 01-01-1900? 

In the yellow part you add the filter expression, like you did, but just Var.compared>0 .

 

 

 


compareTo.jpg
Anonymous
Not applicable
Author

Tried like you showed but it gives me this error:

 

java.lang.IllegalArgumentException: java.lang.ClassCastException@795bb42d
	at sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:461)
	at org.talend.designer.codegen.config.TalendJetEmitter.generate(TalendJetEmitter.java:684)
	at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:441)
	at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:432)
	at org.talend.designer.codegen.proxy.JetProxy.generate(JetProxy.java:54)
	at org.talend.designer.codegen.CodeGenerator.instantiateJetProxy(CodeGenerator.java:446)
	at org.talend.designer.codegen.CodeGenerator.generateContextCode(CodeGenerator.java:363)
	at org.talend.designer.core.runprocess.Processor.updateContextCode(Processor.java:642)
	at org.talend.designer.runprocess.java.JavaProcessor.generateContextCode(JavaProcessor.java:1632)
	at org.talend.designer.runprocess.ProcessorUtilities.generateContextInfo(ProcessorUtilities.java:852)
	at org.talend.designer.runprocess.ProcessorUtilities.generateCode(ProcessorUtilities.java:574)
	at org.talend.designer.runprocess.ProcessorUtilities.generateCode(ProcessorUtilities.java:1736)
	at org.talend.designer.runprocess.RunProcessContext$1.run(RunProcessContext.java:582)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:466)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:374)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:527)
	at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:284)
	at org.eclipse.ui.internal.progress.ProgressManager.run(ProgressManager.java:1190)
	at org.talend.designer.runprocess.RunProcessContext.exec(RunProcessContext.java:534)
	at org.talend.designer.runprocess.remote.RunRemoteProcessContext.exec(RunRemoteProcessContext.java:84)
	at org.talend.designer.runprocess.ui.ProcessComposite.exec(ProcessComposite.java:1401)
	at org.talend.designer.runprocess.ui.views.ProcessView$RunAction.run(ProcessView.java:701)
	at org.talend.designer.runprocess.ui.actions.RunProcessAction.run(RunProcessAction.java:58)
	at org.talend.designer.core.debug.JobLaunchConfigurationDelegate$1.run(JobLaunchConfigurationDelegate.java:84)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4147)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3764)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.talend.rcp.intro.Application.start(Application.java:265)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)

What I need to do is to set 01-01-1900 if the date of row1.createddate is equal to prsddate, otherwise I'll set row1.createddate

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...