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

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

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch