Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

convert date into ISO format

Highlighted
Five Stars

convert date into ISO format

Hi Team,

 

I have a date in format "Timestamp -> 2019-47-0610:47:28".

 

I have to convert this date into "ISODate("2019-01-03T09:09:20.002Z")" this format the above timestamp is in long date type.

 

How can we do this in talend?


Accepted Solutions
Highlighted
Community Manager

Re: convert date into ISO format

Ah, your format is wrong. This...

output_row.data_high_timestamp = java.time.format.DateTimeFormatter.ofPattern("yyyy-mm-ddHH:mm:ss").format(java.time.Instant.ofEpochMilli(time_datastart).atZone(java.time.ZoneOffset.UTC));

...should be this.....

output_row.data_high_timestamp = java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-ddHH:mm:ss").format(java.time.Instant.ofEpochMilli(time_datastart).atZone(java.time.ZoneOffset.UTC));

You have given the minutes as months. There are not 47 months in a year :-)

 

 

 

View solution in original post


All Replies
Highlighted
Community Manager

Re: convert date into ISO format

What date does 2019-47-0610:47:28 represent?

Highlighted
Five Stars

Re: convert date into ISO format

Hi,

 

It's time in date format:-

output_row.data_high_timestamp = java.time.format.DateTimeFormatter.ofPattern("yyyy-mm-ddHH:mm:ss").format(java.time.Instant.ofEpochMilli(time_datastart).atZone(java.time.ZoneOffset.UTC));

 

time_datastart ->

time_datastart = ((Double)(jsonArray.getJSONArray(0).get(0))*1000);

 

and in datetype I am using Date format "yyyy-MM-dd hh:mm:ss".

Highlighted
Community Manager

Re: convert date into ISO format

Ah, your format is wrong. This...

output_row.data_high_timestamp = java.time.format.DateTimeFormatter.ofPattern("yyyy-mm-ddHH:mm:ss").format(java.time.Instant.ofEpochMilli(time_datastart).atZone(java.time.ZoneOffset.UTC));

...should be this.....

output_row.data_high_timestamp = java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-ddHH:mm:ss").format(java.time.Instant.ofEpochMilli(time_datastart).atZone(java.time.ZoneOffset.UTC));

You have given the minutes as months. There are not 47 months in a year :-)

 

 

 

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 2

Part 2 of a series on Context Variables

Blog

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