Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey,
I have a column with strings like "2019-03-17 08:42:09 +0400" . Do anybody know how to make this to date and add +0400 to my datetime with java ?
Please help me. Thanks a lot
If you want to print
in tJavaRow :
System.out.println(TalendDate.formatDateInUTC("yyyy-MM-dd HH:mm:ss Z",TalendDate.parseDate("yyyy-MM-dd HH:mm:ss Z",input_row.newColumn )));
you can assign to variable
String dateUTC = TalendDate.formatDateInUTC("yyyy-MM-dd HH:mm:ss Z",TalendDate.parseDate("yyyy-MM-dd HH:mm:ss Z",input_row.newColumn ));
Thanks for your quick response but how i add this method to a variable in order to print the result in java. If it was in tmap it would be easy but I am a bit confused with java components.
If you want to print
in tJavaRow :
System.out.println(TalendDate.formatDateInUTC("yyyy-MM-dd HH:mm:ss Z",TalendDate.parseDate("yyyy-MM-dd HH:mm:ss Z",input_row.newColumn )));
you can assign to variable
String dateUTC = TalendDate.formatDateInUTC("yyyy-MM-dd HH:mm:ss Z",TalendDate.parseDate("yyyy-MM-dd HH:mm:ss Z",input_row.newColumn ));
Use the below custom code in a tJavaRow component.
TimeZone.setDefault(TimeZone.getTimeZone("UTC")); String [] date = input_row.input_date.split(" "); int hour = Integer.parseInt(date[2])/100; int mins = (Integer.parseInt(date[2])%100); Date date_new = TalendDate.TO_DATE(date[0]+" "+date[1], "yyyy-MM-dd HH:mm:ss"); date_new = TalendDate.addDate(date_new, hour, "HH"); date_new = TalendDate.addDate(date_new, mins, "mm"); output_row.output_date = date_new;