tMap Expression Builder Conditional logic java lang Error
Hello Team,
Currently I'm working on a way to compare the data coming from two different excel sheets, I'm using two tFileInputExcel then doing some data transformations using tJavaRows (parsing dates, and some strings containing numbers to integer). After doing this Im receiving the two inputs into a tMap in which I need to compare two rows in order to divide the information.
In order to compare the row I need from the input1 and the one from the input2, I have a conditional as follows (An example of what I'm doing):
row10.field4>row12.field4?row10.field3:row12.field3
When running the program I am getting the error "Caused by: java.lang.Error: java.lang.Error: Unresolved compilation problems: row12 cannot be resolved to a variable"... it does not recognize the row12 elements..
Is there a way I could use the values from the second input in the tMap? Making long story short, in both excel sheets I have a date from which I extract the hour (myDate.getHours()+":"+myDate.getMinutes()+":"+myDate.getSeconds()) and then from this I get, on a field apart, the minutes (in both tJavaRows), what I need to do is to put in an excel, as incorrect, the data in which the hour from the input1 exceeds the hour from the input2 in 15 minutes or more than 15 minutes, this and some more validations Im doing in the tMap. Originally in the tMap it rejects every row containing any different information from the input2, the problem is that with the hour, even 1 minute different is taken as incident but the system should let pass if the hour has a difference in minutes of less than 15 minutes
if input1Hour > input2Hour then I verify if input1Hour-input2Hour < = 15 if thats true I let the date from the input1 as the date from the input2 so the inner join will let it go through as OK . if the input1Hour-input2Hour > 15 then I live the date from the input1 exactly as it is so the inner join will reject it as it is supposed to.
Please check the images so you can understand the way Im doing this.
The Date object in Java (what we are dealing with) does not care about format. It is essentially just a number. When we want to see it, we apply a format. I think that your problem actually lies where you convert the data from Excel into a Date object. If this is wrong, then everything else will be.
My suggestion would be to break this down as follows. Test the code you use to create the Date objects from your Excel string dates. Print those out using the format ("yyyy-MM-dd'T'HH:mm:ss"). I imagine you will see some strange dates here. Java will not always reject a badly formatted date, it will use what it has to build a date that fits the configuration you have supplied (or what it thinks fits it). You should spot any issues here. If the correct dates are shown here.
My guess would be that it is something to do with the format expecting 2 digits for a month or a day and you are only supplying 1 digit (2015-1-1 instead of 2015-01-01). Something like that. It is very easily done. But the issue doesn't appear to be with your comparison code.