Converting Text Property into time Format

How to Convert Text Property like 7am or 7pm in the format of 7am =10000101T070000.000 and 7pm=10000101T190000.000 by using functions

@Saivivek To convert a text property like “7am” or “7pm” into the format “10000101T070000.000” or “10000101T190000.000” in Pega, I used a combination of string manipulation and the @FormatDateTime() function. First, I mapped the input like “7am” to “07:00:00 am” and “7pm” to “07:00:00 pm”, so it can be properly formatted using Pega’s date-time functions. Then I appended this time to a dummy date like “10000101” to form a complete date-time string, such as “10000101 07:00:00 am”. Using @FormatDateTime() with the pattern "yyyyMMdd hh:mm:ss a" as input and "yyyyMMdd'T'HHmmss.SSS" as output, I converted this to the desired format. This method ensures that time values are correctly interpreted in 24-hour format while keeping the date constant. For repeated use, I also considered creating a custom function to handle the text-to-time conversion. This helped simplify the logic and avoid hardcoding multiple conditions.

@Sairohith Thank you Very Much For Your Solution

I done it with a different approach for more effective results even when there are spaces present in the input like “7 am” and more like "07 am ","7aM

I Created one Java Function to convert the String type into Specific Format “10000101T070000.000”

Appreciate Your Response