convert string month in date to integer month in talend ("01-jan-2012", "01-01-2012") Urgent help plzz

Six Stars

convert string month in date to integer month in talend ("01-jan-2012", "01-01-2012") Urgent help plzz

Hi,

HOw can i convert string month in date to integer month in Talend using TMap or anything.  Need urgent help

for eg "01-jan-2012" to  "01-01-2012"


Accepted Solutions
Six Stars

Re: convert string month in date to integer month in talend ("01-jan-2012", "01-01-2012") Urgent help plzz

Hi @Chirgal

 

I did this my writing simple code in tjavarow component.

 

//Code generated according to input schema and output schema
output_row.Date = input_row.Date;
//output_row.newdate = input_row.Date;
 
//Code generated according to input schema and output schema
String sample_date = input_row.Date;
//String newdate=null;
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");
Date date = sdf.parse(sample_date);
sdf.applyPattern("dd-MM-yyyy");
output_row.newdate = sdf.format(date);

All Replies
Eight Stars

Re: convert string month in date to integer month in talend ("01-jan-2012", "01-01-2012") Urgent help plzz

TalendDate.formatDate(TalendDate.parseDate("01-Jan-2012", "dd-MMM-yyyy"),"dd-MM-yyyy")
Six Stars

Re: convert string month in date to integer month in talend ("01-jan-2012", "01-01-2012") Urgent help plzz

@Chirgal,

 It not happening and throwing jVM errors. Please find the screenshot and attached source filedateparse2.PNGdatepart.PNGpaersedate1.PNG

Eight Stars

Re: convert string month in date to integer month in talend ("01-jan-2012", "01-01-2012") Urgent help plzz

My fault try:
TalendDate.formatDate("dd-MM-yyyy",TalendDate.parseDate(row1.Date, "dd-MMM-yyyy"))
Six Stars

Re: convert string month in date to integer month in talend ("01-jan-2012", "01-01-2012") Urgent help plzz

Hi @Chirgal

 

I did this my writing simple code in tjavarow component.

 

//Code generated according to input schema and output schema
output_row.Date = input_row.Date;
//output_row.newdate = input_row.Date;
 
//Code generated according to input schema and output schema
String sample_date = input_row.Date;
//String newdate=null;
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy");
Date date = sdf.parse(sample_date);
sdf.applyPattern("dd-MM-yyyy");
output_row.newdate = sdf.format(date);

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

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