Convert Time in string format to 24 hour format

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.

All Replies
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.
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.

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog