[resolved] Convert float value to date

One Star

[resolved] Convert float value to date

Dear Talend Community,
I have column on my data that contain date like this 31072012 and i should transform it to 31/07/2012
thanks on advanced for help
One Star

Re: [resolved] Convert float value to date

Tranform it to a String and the parse it.
Then create the String you want.
Six Stars

Re: [resolved] Convert float value to date

use below function and replace with actual values. 
you can use it in tJava or tMap`s expression builder. 


TalendDate.parseDate("ddMMyyyy", String.valueOf(31072012));
Four Stars

Re: [resolved] Convert float value to date

Hi,

Following code would convert your input date to required format

System.out.println(TalendDate.formatDate("dd/MM/yyyy",TalendDate.parseDate("ddMMyyyy",String.valueOf(31072012))));

[statistics] connected
31/07/2012
[statistics] disconnected

Thanks
Vaibhav
One Star

Re: [resolved] Convert float value to date

Hi,
I transform my date value to string hawever when i use this function :
TalendDate.parseDate("ddMMyyyy",TalendDate.formatDate("dd-MM-yyyy", row1.DATE_LAST_UPDATE))
then i transformed type of my output column from string to date
but i have this erreur:
  Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    The method formatDate(String, Date) in the type TalendDate is not applicable for the arguments (String, String)
Thanks on advanced for help
One Star

Re: [resolved] Convert float value to date

Hi,
I transform my date value to string hawever when i use this function :
TalendDate.parseDate("ddMMyyyy",TalendDate.formatDate("dd-MM-yyyy", row1.DATE_LAST_UPDATE))
then i transformed type of my input and output column from string to date
but i have this erreur:
  Unparseable date: "31/07/2012"

Thanks on advanced for help
One Star

Re: [resolved] Convert float value to date

Hi Sanvaibhav,
I use your function but i have this erreur

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from void to Date

However should i transform type value for my input and output on Tmap
Seventeen Stars

Re: [resolved] Convert float value to date

hi, 

read carefully what sanvaibhav's told you.
you have just to replace 31072012 by your data flow row1.DATE_LAST_UPDATE, and it should works.

regards
laurent
Four Stars

Re: [resolved] Convert float value to date

TalendDate.parseDate("ddMMyyyy",TalendDate.formatDate("dd-MM-yyyy", String.valueOf(row1.DATE_LAST_UPDATE)))


This should work.


Vaibhav

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

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog