on 04-05-2015 6:42 PM
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) |
02/2016 | 20160229 (February 29 2016) |
02/2015 | 20160228 (February 28 2015) |
06/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.
Hi Sree
I tested your UDF code on my PO 7.4 system and it works fine. But like you said, the issue occurrence is very rare. Additionally, PI 7.0 runs on Java 1.4 whilst PO 7.4 is on 1.6.
Anyway, I just wanted to share with you my own experience working with Date and Time in Java. Apparently in the Java community, the standard date and time classes prior to Java 8 are considered to be poor. I'm not sure if this might contribute to the inconsistent results you are getting, especially since Java 1.4 is really old.
The de facto standard for Java date and time libraries prior to Java 8 is Joda Time. Check it out at the following link.
You can try using their libraries in your UDF instead and see if it solves the inconsistent result issue.
Rgds
Eng Swee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.