How do you keep the same date format coming from mssqlinput?
Sqlserver date is 2018-06-14 11:44:40.320
When mssqlinput passes a date column to tJavaRow the date output is different in the run console.
Result from run console
Input Date: Thu Jun 14 11:44:40 CDT 2018
Even I tried converting it in tJavaRow and get the same result.
context.run_date = (TalendDate.parseDate("yyyy-MM-dd HH:mm:ssSS",TalendDate.formatDate("yyyy-MM-dd HH:mm:ssSS",row1.InputStart)));
if ti only for println, You do not need double conversion, use just formatDate
context.run_date_print = (TalendDate.parseDate("yyyy-MM-dd HH:mm:ss.SS",TalendDate.formatDate("yyyy-MM-dd HH:mm:ss.SS",row4.date_as_date))) ; context.run_date_print_string = TalendDate.formatDate("yyyy-MM-dd HH:mm:ss.SS",row4.date_as_date) ; System.out.println("run_date_as_date: "+context.run_date_print); System.out.println("run_date_as_string: "+context.run_date_print_string);
run_date_as_date: Thu Jun 14 11:44:40 NZST 2018 run_date_as_string: 2018-06-14 11:44:40.320
I think a bigger issue needs tackling here. Dates are NOT stored with formats. They are simply numbers. Your Date format is just how your device makes it human readable to you. When you want to write a date to a String or use a date in a SQL query, you will have to format it because it is being converted to a different class. But if you are simply passing a date as a date class, formats are irrelevant.
I think you may have misunderstood what I was getting at @vapukov. The "issue" here is that too many developers seem confused by Dates and expect them to be formatted as part of the object. This misunderstanding leads to lots of questions and confusion over Dates with Talend.