Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a problem. I'd like to extract the day froma a date but it will have missing value --> " ". How can I extract the day from dates that have no null values? Thanks
I have this exception message:
Exception in component tMap_1
java.lang.NullPointerException
at l10001_servicenow_timeworked.l10001_sn_0_1.L10001_SN.tFileInputXML_1Process(L10001_SN.java:8684)
at l10001_servicenow_timeworked.l10001_sn_0_1.L10001_SN.runJobInTOS(L10001_SN.java:9674)
at l10001_servicenow_timeworked.l10001_sn_0_1.L10001_SN.main(L10001_SN.java:9531)
I don't see the line number!
It's very big. Can you tell me in which way I can export the day from a day only if this record is Empty???
example: date1 -> 2017-05-27 11:30:15 day -> 27 ....
date2 -> here nothing is stamp!
Here are the date values I use as an example:
This give 2 record, 1 with a value, 1 which is null.
Here is the tMap to get the desired fields (yy, MM, dd and so on):
The syntax I used for each field is based on this one:
row80.fieldDate != null ? Integer.parseInt(TalendDate.formatDate("yyyy", row80.fieldDate)) : null
When the input field is null, of fields on the output flow are null:
HI,
I send you an example of my XML file with a date null.
1. I import all record as String except for integer and boolean;
2. Replace "." with "":
3. Convert String(closed_at and more datetype) in Date ("yyyy-MM-dd HH:mm:ss"):
4. Use tMap for extract the day, month.... from two date (closed_at and sys_updated_on), but closed_at may have null value ("") (see point 2). In this poit Talend give me the error even if I use your function (row1.closed_at != null ? Integer.parseInt(TalendDate.formatDate("dd", row1.closed_at)) : null ) :
this is all. Thanks again!
The field closed_at for the 2nd record is not null, it contains a ".".
So you replace the "." by an empty string "" which is not the same than a null value.
In tReplace, change "" by null and test again.
If you prefer not to change the tReplace, change in tMap for each field (don't forget the "!" at the beginning of the line):
!row80.fieldDate.equals("") ? Integer.parseInt(TalendDate.formatDate("yyyy",row80.fieldDate)) : null
To be sure of which operation fails, click on the Code tab (on the bottom line of the designer workspace) and go to line 9037.
Talend give me this error:
Execution failed : Job compile errors
At least job "L10001_SN" has a compile errors, please fix and export again.
Error Line: 7395
Detail Message: The method closed_at(String) is undefined for the type L10001_SN.row1Struct
There may be some other errors caused by JVM compatibility. Make sure your JVM setup is similar to the studio.
and the code contains:
ok Thanks Thanks Thanks. It's all ok now!