Date comparison in Tmap fails

One Star

Date comparison in Tmap fails

I have two dates, one coming from source and other one from Global.
from source is srce.code_desc_event_date which is string in the format 20131231 and
from global is srce_max_date in date format.
Business rule: Build filter to pass If Global date is NULL or Source Date is >= Global date.
I have following code written but it fails, any help would be greatly appreciated.
((String)globalMap.get("srce_max_date")) == null ||
TalendDate.formatDate("dd-MM-yyyy", TalendDate.parseDate("MM/dd/yyyy",srce.code_desc_event_date)))

thanks in advance.. happy Talend programming to all.
Seventeen Stars

Re: Date comparison in Tmap fails

I guess the value srce_max_date is a Date type object.
(globalMap.get("srce_max_date")) == null || 
TalendDate.parseDate("yyyyMMdd", srce.code_desc_event_date).before((Date) globalMap.get("srce_max_date")) == false

First of all, why do you do not use the format your string get yyyyMMdd and struggle with a lot of converts (all wrong)?
Instead of asking equals or after you could simply ask: not before.