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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
DrGenious
Creator
Creator

Date format

Hey,

 

I have a string with date "17-03-19 9:05" and I want to change the format to "yyyy-MM-dd HH:mm:ss" and the type to be string.

Also I want to convecrt 'May 20 2019 15:30:02 GST" to "yyyy-MM-dd HH:mm:ss"

 

Please help me.Thanks.

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

This code will do it....

String strDate = "May 20 2019 15:30:02 GST ";

Date date = routines.TalendDate.parseDate("MMM dd yyyy HH:mm:ss z", strDate);

System.out.println(strDate);
System.out.println(routines.TalendDate.formatDate("yyyy-MM-dd HH:mm:ss", date));

This page will make figuring this sort of stuff out a bit easier.....

https://docs.oracle.com/javase/10/docs/api/java/text/SimpleDateFormat.html

View solution in original post

3 Replies
Anonymous
Not applicable

You will need to use the TalendDate routines for this (....or use standard Java Date functionality...but the TalendDate routines make it easier). These are described here....

 

https://help.talend.com/reader/QrWkwPvKmKybs~JNLeBt3Q/GF6kKOHdJwnnbGY_b6u02g

DrGenious
Creator
Creator
Author

I figure it out how to do the first one but I need help with the second "May 20 2019 15:30:02 GST "

Anonymous
Not applicable

This code will do it....

String strDate = "May 20 2019 15:30:02 GST ";

Date date = routines.TalendDate.parseDate("MMM dd yyyy HH:mm:ss z", strDate);

System.out.println(strDate);
System.out.println(routines.TalendDate.formatDate("yyyy-MM-dd HH:mm:ss", date));

This page will make figuring this sort of stuff out a bit easier.....

https://docs.oracle.com/javase/10/docs/api/java/text/SimpleDateFormat.html