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

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

View solution in original post


All Replies
Highlighted
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")
Highlighted
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

Highlighted
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"))
Highlighted
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);

View solution in original post

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog