Date format changes before storing as global variable

Five Stars

Date format changes before storing as global variable

I have a tExtractRegexField which looks for a Date string like
 "(\\d{2}-\\D{3}-\\d{2})"

so it will find dates like 01-Feb-16 a.k.a "dd-MMM-yyyy"
That works but I need to store the date in globalmap so I add a tJavaRow as the next component
globalMap.put("MyDate", row3.ReportDate);

In debugging mode I can see the ReportDate as "DayOfWeek MonthAsString DayAsNumber 00:00:00 TimeZone Year"
Is there a way to specify the date format as "dd-MMM-yyyy" as the way to store the date in the globalmap
Ten Stars

Re: Date format changes before storing as global variable

You can convert it to a string before you store it, but then you lose the flexibility of the date format.  You could also convert it to a string with a specific format before printing it.
One Star

Re: Date format changes before storing as global variable

Try this as the field seems to be of String datatype:
globalMap.put("MyDate", StingHandling.LEFT(row3.ReportDate, 11));

It should works.

Regards,
TRF
Five Stars

Re: Date format changes before storing as global variable

Does stringhandling.left just take the 11 chars from the left?
I'd prefer to store it as dd-MMM-yy in string or date format as I can parse it easily enough in tMap. I was a bit surprised the formatting changed as I had the output schema defined as date dd/mmm/yy but at least I know its getting detected as a date
How would I re-enforce the required structure on the string I store in globalMap.put("MyDate", row3.ReportDate);
Java isn't my strong point

What’s New for Talend Spring ’19

Join us live for a sneak peek!

Sign up now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads