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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

ParseException: Unparseable date: "dd.MM.yyyy"

hey guys,
i'm using tos for DI 6.2.1 and i need to parse the first date from the following string in a talend open studio job:
"Report für Benutzerdefiniert Von: 11.10.2016 01:00:00 Bis: 12.10.2016 01:00:00"

I build the following expression which is used in tjavarow component to set the date as global var for later usage:
output_row.Datum = TalendDate.parseDate("dd.MM.yyyy",StringHandling.LEFT(StringHandling.FTRIM(StringHandling.EREPLACE(input_row.Column0,"Report für Benutzerdefiniert Von: ","")),11));
globalMap.put("datum",output_row.Datum);

if i run the job, i just get this error:
Exception in component tJavaRow_2
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "11.10.2016"
   at routines.TalendDate.parseDate(TalendDate.java:895)
   at routines.TalendDate.parseDate(TalendDate.java:839)
   at ec_bi.xxxx_logintimes_csv_to_db_0_1.xxxx_LoginTImes_CSV_to_DB.tFileInputDelimited_3Process(xxxx_LoginTImes_CSV_to_DB.java:3184)
   at ec_bi.xxxx_logintimes_csv_to_db_0_1.xxxx_LoginTImes_CSV_to_DB.tJavaRow_1_error(xxxx_LoginTImes_CSV_to_DB.java:412)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:498)
   at ec_bi.xxxx_logintimes_csv_to_db_0_1.xxxx_LoginTImes_CSV_to_DB$TalendException.printStackTrace(xxxx_LoginTImes_CSV_to_DB.java:355)
   at ec_bi.xxxx_logintimes_csv_to_db_0_1.xxxx_LoginTImes_CSV_to_DB.runJobInTOS(xxxx_LoginTImes_CSV_to_DB.java:10195)
   at xxx.xxxxxx_csv_to_db_0_1.xxxx_LoginTImes_CSV_to_DB.main(xxxx_xxxxx_CSV_to_DB.java:9946)
Caused by: java.text.ParseException: Unparseable date: "11.10.2016"
   at java.text.DateFormat.parse(DateFormat.java:366)
   at routines.TalendDate.parseDate(TalendDate.java:881)
   ... 10 more

the inner expressions result seems to be correct and the reuslt is: "11.10.2016"  but whats wrong with 
TalendDate.parseDate("dd.MM.yyyy",...) ?
THANKFULLY
christian
Labels (3)
3 Replies
Anonymous
Not applicable
Author

UPDATE: 
if I run: 
output_row.datum = TalendDate.parseDate("dd.MM.yyyy",StringHandling.TRIM(StringHandling.LEFT(StringHandling.EREPLACE(input_row.Column0,"Report für Benutzerdefiniert Von: ",""),10)));

i get 

java.lang.RuntimeException: java.text.ParseException: Unparseable date: "10.10.201"

what means that there seems to be a character which is not visible, how can i figure out what it is and how can i determine it easily ??
Anonymous
Not applicable
Author

and ladies gentlemen, the solution or better the workaround is:
output_row.datum = TalendDate.parseDate("dd.MM.yyyy",StringHandling.TRIM(StringHandling.RIGHT(StringHandling.LEFT(StringHandling.EREPLACE(input_row.Column0,"Report für Benutzerdefiniert Von: ",""),11),10)));


but is there a more glaceful solution?
cterenzi
Specialist
Specialist

Does the  "Report für Benutzerdefiniert Von: " portion of your string ever vary?  If not, you can try something like:
output_row.Datum = TalendDate.parseDate("dd.MM.yyyy", input_row.Column0.substring(35,46));

Remember, you have full access to Java's String methods.  You don't need to rely solely on the ones Talend includes for you.