Get Day of Week in Full string

Hi,

Pega Provides feasibility to get weekday in Integer. suppose if we want to get String Name?

Example : 11-May-2021 - Pega gives output from weekday function - 3

If we need full string we can use below approaches :

  1. FormatDateTime function will help to get Pattern of day in string with (EEEEE)

@(Pega-RULES:DateTime).FormatDateTime(“20210511T155844.968 GMT”, “EEEEE”, “”, “”)

  1. we can write an function, which can have library

Java.time.*

Integer intobject = new Integer(parseDay);
int d = intobject.intValue();
d= d-1;
DayOfWeek day = DayOfWeek.of(d);
return day.name();

Note: Why we are subtracting by 1 is pega weekday will give values from 1 as sunday, java will give 0 as sunday. that is the reason we are subtracting.

@KarthickM6092

One more approach is by leveraging Decision Table:

  1. Get the day number in a parameter using weekday function. It will return the day number which lies between(1-Sunday to 7-Saturday).

  2. Pass the parameter to a decision table where for each day number we can configure corresponding day name. When this is triggered it will return the day name.

@KarthickM6092 - Good one Karthick. I like the OOTB function with “EEEEE” option. Looks like something missed from your java code, that is fine. Here is another way of writing the java code for the same context. Result is the Local parameter in Pega and we can define it in the activity and print on the screen using Show-Property.

java.util.Date date = new java.util.Date();
String tempDate = date.toString();
java.time.LocalDate date = java.time.LocalDate.parse(tempDate);
java.time.DayOfWeek day = date.getDayOfWeek();
Result=day.toString();