Convert Time in string format to 24 hour format

Highlighted
Five Stars

Convert Time in string format to 24 hour format

Hello Everyone,

 

Need help on this !!

 

I am trying to convert a time of type string into a date of 24 hour format.

 

Input string : "11:59:00 PM"

Tmap Expression : "TalendDate.parseDate("HH:mm:ss", row6.Start_Time) 

Output date 11:59:00.0000000

Expected: 23:59:00.0000000

 

 

Tags (1)

Accepted Solutions
Highlighted
Ten Stars

Re: Convert Time in string format to 24 hour format

"HH" in a date format string implies 24 hour time. If you have AM/PM in your strings, use "hh".

As for the output, once your string is converted to a Date object, you can format the output however you want. If you need to print the date, you can use TalendDate.formatDate() for that. You can also influence the output format by setting the Date Pattern for that column in your schema. In that case, you'd want the pattern to be "HH:mm:ss" to print 24 hour time.

View solution in original post


All Replies
Highlighted
Ten Stars

Re: Convert Time in string format to 24 hour format

Your date pattern needs to be "hh:mm:ss a" to capture the AM/PM designation.
Five Stars

Re: Convert Time in string format to 24 hour format

Thank you for your reply. I tried that and it still doesn't convert to 24 hour format.

TalendDate.parseDate("HH:mm:ss a",row3.Start_Time )

Highlighted
Ten Stars

Re: Convert Time in string format to 24 hour format

"HH" in a date format string implies 24 hour time. If you have AM/PM in your strings, use "hh".

As for the output, once your string is converted to a Date object, you can format the output however you want. If you need to print the date, you can use TalendDate.formatDate() for that. You can also influence the output format by setting the Date Pattern for that column in your schema. In that case, you'd want the pattern to be "HH:mm:ss" to print 24 hour time.

View solution in original post

Highlighted
Five Stars

Re: Convert Time in string format to 24 hour format

worked !! Missed that in your first note Smiley Happy Thank you so much. Appreciate it.

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