Custom Pega Function - Add three Months to Date
Hi,
In this blog we will see now to create our own custom function for adding 3 months to Date.
Before Creating our function we need to create Library (Data Instance Rule).
Go to Records --> Technical --> Library (Right click create)
Library Name = ArtLib
RuleSet Name = Art
In Packages Tab, inside Java packages to Include
1) java.io.*;
2) java.util.*;
3) javax.xml.transform.*;
4) javax.xml.transform.stream.*;
5) java.time.*;
6) java.time.format.*;
7) java.time.temporal.*;
{checked} Library ready to compiled?
Now,
Go to Records --> Technical --> Function --> Right Click Create
Function Name = AddthreeMonthsToStringDate-(String)
Parameters (TAB)
Input parameters
StrDate String (Java type)
Output
Java data type = String
Pega type = Text
Java (TAB)
LocalDate local_date_1;
LocalDate local_date_2;
DateTimeFormatter formatter_1 = DateTimeFormatter.ofPattern("yyyyMMdd");
String str_date_1 = StrDate;
Local_date_1 = LocalDate.parse(str_date_1,formatter_1);
local_date_2 = local_date_1.plusMonths(3);
String str = local_date_2.toString();
String result = str.replace("-","");
return result
To test above created function, Open Data Transform or Activity and use expression builder
Comments
Post a Comment