You are not logged in.

#1 2009-05-26 23:09:38

sahanakrish
Member
10 posts

Date validation

Is there a way to validate the datetime in talend?

is there any method like isValidDate(<<myString as string>>, <<myDateFormat as string>>) return 0 or 1 for OK or Not OK ??

I have feeds that come in with junk data time ---check  the month below
In such cases when i format the date to yyyy-MM-dd HH:mm:ss  i will get 2008-99-02 15:21:22.. which has invalid month.. and i have to reject the feed and not process it ..

<date year="2008" month="99" date="2" />
<time hour="15" minute="21" second="43" />

Thanks,
Sahana

Offline

#2 2009-05-27 03:00:52

shong
Talend Team


Re: Date validation

Hello Sahana
Try the method isDate(String stringDate, String pattern) provided by Talend. eg:

TalendDate.isDate("2008-99-02 15:21:22", "yyyy-MM-dd HH:mm:ss")

Best regards

        shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the global leader of open source data management and application integration solutions!

Offline

#3 2009-08-01 00:42:17

tnewman
Member
194 posts

Re: Date validation

Shong,

I am trying :-

TalendDate.isDate(keyed_workorders.TARGET_START_DT, "MM/dd/yyyy HH:mm:ss")

where the TARGET_START_DT is defined as a Date type.

I get error Method is undefined for isDate.

Any ideas?


------------------
Talend Version - TIS 4.1.2
Generated Code - Java
OS - WinXP SP3 / Linux

Offline

#4 2009-08-02 05:00:41

shong
Talend Team


Re: Date validation

Hello guy

where the TARGET_START_DT is defined as a Date type.

The data type of first parameter is String and this method returns a boolean value.

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the global leader of open source data management and application integration solutions!

Offline

#5 2009-08-06 22:36:20

Trevor
Guest

Re: Date validation

Shong,

Whats the best way to convert a date defined field ot a string so that I can use te isdate check?

Also what version of talend was the isdate check valid in?

#6 2009-08-07 03:13:55

shong
Talend Team


Re: Date validation

Hello  Trevor

Whats the best way to convert a date defined field ot a string so that I can use te isdate check?

To convert a date to a string, you can use method:
TalendDate.formatDateLocale(String pattern, java.util.Date date, String languageOrCountyCode)
The isDate method is be used to check if a date with string format matchs the specify pattern.

Also what version of talend was the isdate check valid in?

I remenbered it is present since TOS3.0

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the global leader of open source data management and application integration solutions!

Offline

#7 2010-05-06 02:33:27

dragonvoice
Member
2 posts

Re: Date validation

Hello, shong

I am a newbie to Talend, a newbie to Java, and also a newbie who only started working this year...

So I will ask a very very stupid question...

Where do I insert the code? Do I just click 'Advance Mode' in the tFilterRow and type in the code you illustrated above?

(What I need to do is to validate a series of dates, say three columns of date, and ouput them into a comma delimited file if those columns are empty or not a valid date or not in the specified date format.)

Thanks heaps!!

Dragonvoice

Offline

#8 2010-05-06 05:18:18

shong
Talend Team


Re: Date validation

Hello

Where do I insert the code? Do I just click 'Advance Mode' in the tFilterRow and type in the code you illustrated above?

You can insert the Java code in any text filed, such as 'Advance Mode' in the tFilterRow, the file name filed in tFileInputDelimited, tJava.

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the global leader of open source data management and application integration solutions!

Offline

Board footer