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"

Tags (3)
1 ACCEPTED SOLUTION

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);
4 REPLIES
Six 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

Six 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);