From Thursday, July, 9, 3:00 PM Pacific,
our Community site will be in
read-only mode
through Sunday, July 12th.
Thank you for your patience.

Date format

Highlighted
Seven Stars

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.


Accepted Solutions
Community Manager

Re: Date format

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


All Replies
Highlighted
Community Manager

Re: Date format

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

Highlighted
Seven Stars

Re: Date format

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

Community Manager

Re: Date format

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

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog