cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for mapping running week's Sunday as week end date

chetan_risbud
Participant
0 Kudos

Hello experts,

I need UDF to map WeekendDate field as running week Sunday's date, where Monday is Week start day.

Accepted Solutions (1)

Accepted Solutions (1)

former_member186851
Active Contributor
0 Kudos

Hello Chetan,

you have B2B kit installed in the PI ESR.

Check if any of the Standard functions  in the below link will help you out

Importing User Defined Functions - SAP NetWeaver Process Integration, business-to-business add-on 1....

Answers (1)

Answers (1)

vkaushik82
Active Participant
0 Kudos

Try below Code

     Calendar date = Calendar.getInstance();

       

         int diff = Calendar.SUNDAY - date.get(Calendar.DAY_OF_WEEK);

         if (!(diff > 0)) {

             diff += 7;

         }

         date.add(Calendar.DAY_OF_MONTH, diff);

         String strdate = null;

         SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

         if (date != null) {

         strdate = sdf.format(date.getTime());

         }

       return strdate;