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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Problem converting from Date to BigDecimal

Hello.
I have an excel file with a Date column with pattern "dd/MM/yyyy" and I want to store that value in an oracle table but in number(6) format.
For example, in my excel file I have "11/10/2013" and I want to store it in oracle like 201310
What I do is tFileInputExcel_1 ---> tMap_1 ---> tConvertType_1 ---> tOracleOutput_1
The datatypes in each component are:
tFileInputExcel : Field Fecha_Exp, type Date, Date Pattern "dd/MM/yyyy"
tMap : in the output field I have this: TalendDate.formatDate("yyyyMM",row1.Fecha_Exp) to a output field type String
tConvertType : Autocast, in the input schema the field is a string, in the output schema the field is a BigDecimal
tOracleOutput : the final datatype of the destination field is BigDecimal
It doesn't work, the error is this:
Exception in component tMap_1
java.lang.NullPointerException
at java.util.Calendar.setTime(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.SimpleDateFormat.format(Unknown Source)
at java.text.DateFormat.format(Unknown Source)
at routines.TalendDate.formatDate(TalendDate.java:136)
at coste_distribucion.carga_r_0_1.carga_r.tFileInputExcel_1Process(carga_r.java:1505)
at coste_distribucion.carga_r_0_1.carga_r.runJobInTOS(carga_r.java:2018)
at coste_distribucion.carga_r_0_1.carga_r.main(carga_r.java:1886)

Any help? Thanks in advance.
Labels (3)
4 Replies
Anonymous
Not applicable
Author

Hi,
There is "java.lang.NullPointerException" error in tMap, would you mind uploading the tMap editor screenshot into forum so that we can get the current mapped row structure.
Best regards
Sabrina
Anonymous
Not applicable
Author

Here it is
0683p000009MArN.jpg
Anonymous
Not applicable
Author

Hi,
The method "TalendDate.formatDate(String pattern, java.util.Date date)" Formats a Date into a date/time string not Date.(I suspect which makes java.lang.NullPointerException )
In you case, you want to get a BigDecimal.
Please try this expression:
new BigDecimal (TalendDate.formatDate("yyyyMM",row1.date))

See my screenshots for details
Best regards
Sabrina
0683p000009MB7K.png 0683p000009MAry.png
Anonymous
Not applicable
Author

Hi,
Any update for your issue? Feel free post your issue on forum.
Best regards
Sabrina