Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Labels (2)
7 Replies
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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?
Anonymous
Not applicable
Author

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
_AnonymousUser
Specialist III
Specialist III

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?
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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