Skip to Content
Former Member
Apr 05, 2015 at 05:42 PM

Issue With Java code in UDF


Hi All,

i have a very weird behaviour in SAP PI 7.0 with java code in UDF

the Code has which will put Max Day of the month of the respective year (following the actual calendar) for a given date & month

Input (mm/yyyy)

What we want (yyyymmdd)


20160229 (February 29 2016)


20160228 (February 28 2015)


201506230 (June 30 2015)

Below is the Java code

Calendar c = Calendar.getInstance();

int mon = Integer.parseInt(month)-1; //Month Starts from 0-Jan till 11-Dec in Java

int yr = Integer.parseInt(year);

c.set(Calendar.MONTH, mon);

c.set(Calendar.YEAR, yr);

int days = c.getActualMaximum(Calendar.DAY_OF_MONTH);

String lastDay = Integer.toString(days);

return (year+month+lastDay);

For Certain dates, For Example 02/2018 it is sent as 31022018 which is incorrect

I dont see any issue in Java code

Also This issue is very Rare Occurrence, It occured 250+ times in 750000 times

Please let me know if any one know any pointers about this.