Question

TimeOfDay property format conversion

HI,

I am facing one issue. I have a Data type has 3 rows and each row is havin a TimeOfDay property set.

Now I want to display this TimeOfDay property as drop down which I am able to achieve but it is giving Pega's TimeOfDay format i.e. HHmmss. Now I would like to format it to HH:mm or in AM/PM format. but I can't find any article in pega or any help in google. Please help .

Comments

Keep up to date on this post and subscribe to comments

Pega
November 17, 2019 - 6:19am

Hi Madhusudan,

Thanks for posting the query. Please follow the below approach which might be helpful to achieve the posted requirement.

Create an activity with the below java step on passing the input data as parameters to it and get the date in the required format.

String formattedDate = "23:30:00"; // input date time as parameter

    DateFormat readFormat = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
    DateFormat writeFormat = new SimpleDateFormat( "hh:mm a", Locale.getDefault());

    Date date = null;

    try {
        date = readFormat.parse(dateStr);
    } catch (ParseException e) {
    }

    if (date != null) {
        formattedDate = writeFormat.format(date);
    }