cancel
Showing results for 
Search instead for 
Did you mean: 

Checking date format in XI mapping

Former Member
0 Kudos

Hi all,

I have a scenario in which the need arises for checking the date format.The source field has to be checked whether having the format YYYYMMDD.How can I handle this?

Thanks and Regards,

Jishi

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Jishi,

I think Jithesh's function should solve your problem. Did it?

cheers,

Prashanth

Former Member
0 Kudos

Hi

Write a user defined function

where u can use the java code

Format formatter = new SimpleDateFormat("yyyy/MM/dd");

here u can specify the required date format.

so ur input will be a string with the date,

so convert the date string into a Date object and then format the date according to ur need.

Date dtobj = new Date(strgDate); //convert the string into date object.

Format formatter = new SimpleDateFormat("yyyy/MM/dd"); //specify the required format.

formatter.format(dtobj); //format ur date

return dtobj;

cheers

jithesh

Former Member
0 Kudos

Hi,

I want to check whether the date is having the correct input.For e.g. the source date should not have day as not more than 31 and month should not be more than 12.

Thanks,

Jishi

Former Member
0 Kudos

Hey,

U can use substring function

and get the date,month and year from the date string

and seperately check whther the given date is not more than 31 or check if month is not more tha 21.

so it will be

String strdate,strmonth;

strdate=substring(datestring,beginposition,endposition);

strmonth=substring(datestring,beginposition,endposition);

then check the conditon using if statement.

cheers

jithesh

bhavesh_kantilal
Active Contributor
0 Kudos

Jishi,

This can be done using an UDF.

String inputdate= YYYYMMDD;
int month=Integer.parseInt(inputdate.substring(4,6));
int date=Integer.parseInt(inputdate.substring(6,inputdate.length()));
if((month>=1&&month<=12)&&(date>=1&&date<=31){
return "VALID";
}
else{
return "INVALID";

}

Regards,

Bhavesh

Former Member
0 Kudos

Hi ,

you can check this with standard functions also...

http://help.sap.com/saphelp_nw04/helpdata/en/2c/2d8c4024d26e1de10000000a1550b0/content.htm ...

sekhar

Former Member
0 Kudos

Hi Jishi,

You can write a user defined function to check the same.

cheers,

Prashanth