Six Stars

HOW TO GET FILEDATE IN TMAP

hi ,

 

how to get filedate. myfilename is pk_20110504124523.csv

i need the date format like this 2011-05-04 12:45:23

 

i tried like this  ((String)globalMap.get("tFileList_2_CURRENT_FILE")).sub string(3,17) .am getting like this 20110504124523.

can any one help me.

  • Data Integration
  • Exchange components
  • Talend Integration Cloud
Tags (1)
2 ACCEPTED SOLUTIONS

Accepted Solutions
Nine Stars

Re: HOW TO GET FILEDATE IN TMAP

try this

 

TalendDate.parseDate("yyyyMMddHHmmss",((String)globalMap.get("tFileList_2_CURRENT_FILE")).sub string(3,17)) 

with column type Date and pattern "yyyy-MM-dd HH:mm:ss" it must return proper result

-----------
Nine Stars

Re: HOW TO GET FILEDATE IN TMAP


k526 wrote:
cannot convert from date to string

of course, because - it return Date (see my message)

 

if need string - add one more function formatDate() - it return string

TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",TalendDate.parseDate("yyyyMMddHHmmss",((String)globalMap.get("tFileList_2_CURRENT_FILE")).sub string(3,17)) )
-----------
4 REPLIES
Nine Stars

Re: HOW TO GET FILEDATE IN TMAP

try this

 

TalendDate.parseDate("yyyyMMddHHmmss",((String)globalMap.get("tFileList_2_CURRENT_FILE")).sub string(3,17)) 

with column type Date and pattern "yyyy-MM-dd HH:mm:ss" it must return proper result

-----------
Six Stars

Re: HOW TO GET FILEDATE IN TMAP

Thank you so much this is working fine

Nine Stars

Re: HOW TO GET FILEDATE IN TMAP


k526 wrote:
cannot convert from date to string

of course, because - it return Date (see my message)

 

if need string - add one more function formatDate() - it return string

TalendDate.formatDate("yyyy-MM-dd HH:mm:ss",TalendDate.parseDate("yyyyMMddHHmmss",((String)globalMap.get("tFileList_2_CURRENT_FILE")).sub string(3,17)) )
-----------
Nine Stars

Re: HOW TO GET FILEDATE IN TMAP

Welcome! :-)

-----------