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: 
BeginnerNeedsHelpPlease

struggling with parseDate when I try System.out.println(TalendDate.parseDate("dd-MM-yyyy HH:mm:ss", "13-10-2010 12:23:45"));

Hello

I understand TalendDate.parseDate changes a string into a Date.

It is supposed to returns a date in the specified format, but i don't know how to specify the format.

 

I understand the arguments in the function are below in bold:

TalendDate.parseDate("format date of the string to be parsed", "string in the format of the date to be parsed")

As such, I never specify the format when I return the result

 

For example, I have a tjava and i do:

System.out.println(TalendDate.parseDate("dd-MM-yyyy HH:mm:ss", "13-10-2010 12:23:45"));

and it returns this result:

Wed Oct 13 12:23:45 CEST 2010

I never specifiied I want Day of week, Month, Day, Time, CEST Year...

instead I want the result to be YEAR MONTH DAY

I don't care about the time,

how can I specify the final format and the result should also be a date and not a string?

is it possible?

thank you

Labels (2)
2 Replies
Anonymous
Not applicable

Hello @adi nul​ ,

The default date format for System.out.println(date1) is "EEE MMM dd HH:mm:ss z yyyy"

if you want to change the output date format, you can use another method System.out.printf() like

System.out.printf("%tY-%<tm-%<td", date1);

​For your case, to keep the date type and specify the final format, you can use tMap component to convert the date and setup the Date Pattern to "yyyy-MM-dd" like the below

0695b00000htM6DAAU.pngBest regards

Aiming

 

jlolling
Creator III
Creator III

You should never rely on the default behaviour of the JVM version. The default format for the Date-2-String conversion is always a matter of change. Please use always the TalendDate routines to convert Strings to Date and Date to String.