[resolved] How to parse date with single-digit month or year

One Star

[resolved] How to parse date with single-digit month or year

Trying to parse dates with a tFileInputDelimited and a date pattern of "dd-MM-yyyy HH:mm:ss", I am getting the error "Unparseable date: 8/13/1949 0:00:00". I assumed this was because the month is only a single digit instead of the expected two.
So digging into the source code of ParserUtils.java and FastDateParser.java, it seems that my date pattern must be from java.text.SimpleDateFormat, which would suggest that it needs to be "d-M-yyyy H:mm:ss"... but that doesn't work either.
Is there a better date pattern to use that will accept single or double-digit months/days/hours? Or do I need to find another way to parse these?

Accepted Solutions
One Star

Re: [resolved] How to parse date with single-digit month or year

Doh! It was simple thoughtlessness on my part: I had swapped the "month" and "day" values in the pattern string, so of course it's going to fail when the "month" is over 12! Even sillier, I had dashes instead of slashes, so of course it didn't match.
Maybe I should go work on something else for a while...

View solution in original post


All Replies
One Star

Re: [resolved] How to parse date with single-digit month or year

Doh! It was simple thoughtlessness on my part: I had swapped the "month" and "day" values in the pattern string, so of course it's going to fail when the "month" is over 12! Even sillier, I had dashes instead of slashes, so of course it didn't match.
Maybe I should go work on something else for a while...

View solution in original post

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