Hi All I have a date in my input files which is of string type and i want my output should be in date data type and format should be "yyyy/MM/dd" The input can have more than one date format.I tried all the ways which are provided in the forum I tried using FormateDate() and parseDate() methods but i couldn't able to convert . Can anyone help me in this and which methos is most appropriate among the 2 methods.
Hi lmit, If input contains different date formats, do you have any logical method to understand that this particular date is in specific format, so that we can apply appropriate transformation to convert date. In order to format or parse date, we need to provide date format string, else it can't convert. And this is something can't be automated using existing functions. But using some rule based method, we can try to devise some logic, but need to understand the business scenarios for input dates. Thanks vaibhav
I tried using the following and none of them seemed to work. I was hoping to set this as the default value if nothing was provided. Date() --> The method Date() is undefined for the type MDMGameSystem_Load TalendDate.getDate("yyyy-mm-dd") --> the method put(String, String) in the type Map<String, String> is not applicable for the arguments (String, Date) Type mismatch: cannot convert from Sting to Date TalendDate.getCurrentDate() --> the method put(String, String) in the type Map<String, String> is not applicable for the arguments (String, Date) TalendDate.formatDate("yyyy-MM-dd", new Date()) --> Type mismatch: cannot convert from Sting to Date the method put(String, String) in the type Map<String, String> is not applicable for the arguments (String, Date) TalendDate.parseDate("yyyy-MM-dd", TalendDate.getCurrentDate()) --> Exception in thread "main" java.lang.Error: Unresolved compilation problem
Hi, I tried with "yyyy/MM/dd" formatted string. Both of these example give me correct results: ex 1: TalendDate.parseDate("yyyy/MM/dd",a.newColumnDate) ex 2: new java.text.SimpleDateFormat("yyyy/MM/dd").parse(a.newColumnDate) If you have many possible formats to test, I think that a custom routine that use SimpleDateFormat (I presume you have to use cascading conditional blocks) is more useful. bye