cancel
Showing results for 
Search instead for 
Did you mean: 

Date Format Validation in Message Mapping

Former Member
0 Kudos

Gurus,

I wanted to validate the date before passing that to "dateTrans" function. If the date is not valid then I need to pass and error information to the target for the particular record. I need help in validating the date format. I am expecting the date format as MM/DD/YYYY . How to validate the date. If any other date format or error data coming I need to validate.

Please help.

Kevin

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Refer this udf for help -/people/robin.schroeder/blog/2006/11/21/dynamic-date-conversion-in-message-mapping

Pass the source date, target date formats (constants) and date as input.

In the exception block return the error message you want to send.

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Kevin Joseph,

Use this UDF.

public String dateValidate(String inputDate, Container container) throws StreamTransformationException{
try
{
   java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MM/dd/yyyy");
   if(inputDate.equals(sdf.format(sdf.parse(inputDate))))
    {
     return inputDate;
    }else{
    return "Date is not valid";
    }
} catch(java.text.ParseException pE)
 {
  return pE.toString() + "Wrong date format";
 }

}

Regard,

Raghu_Vamsee

pedro_baroni3
Active Contributor
0 Kudos

Hi Kevin,

You can use a Graphical Mapping as:

[http://www.freeimagehosting.net/39ebe]

But it is better to use a Java UDF.

Regards.