Question


Veteran Careers First
US
Last activity: 7 Feb 2019 9:18 EST
JAVA step to convert Julian date
Can some provide screen shot of Activity JAVA step used to convert Julian date to MM/DD/YYYY
Ex: 2019035 = 02/04/2019
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution


Pegasystems Inc.
US
To use the Parameter you should follow the below steps:
- Create a "Input" parameter in your activity of type String and INPUT.
- Replace your java code with below code,
String paramValue= (String) tools.getParameterPage().getParameterValue("Input");try{
java.text.DateFormat fmt1 = new java.text.SimpleDateFormat("yyyyDDD");
Date date = fmt1.parse(paramValue);
java.text.DateFormat fmt2 = new java.text.SimpleDateFormat("MM/dd/yyyy");
Output = fmt2.format(date);
}
catch(java.text.ParseException e){
oLog.info("Parsing error : " + e);
}
This way you can input the date value to your activity.


Pegasystems Inc.
US
Hi Henry,
You can try to use the SimpleDateFormat class to get the calendar date format DD/mm/yyyy from the julian date format with the same code attached. Hope this will help you to achieve your requirement.
Regards,
Mahesh M


Veteran Careers First
US
I am getting "delete tokens" error and "Invalid syntax"
See Attachment


Pegasystems Inc.
US
Can you copy paste the below code in the Java step and try it,
String input = "2019035";
try{
java.text.DateFormat fmt1 = new java.text.SimpleDateFormat("yyyyDDD");
Date date = fmt1.parse(input);
java.text.DateFormat fmt2 = new java.text.SimpleDateFormat("MM/dd/yyyy");
Output = fmt2.format(date);
}
catch(java.text.ParseException e){
oLog.info("Parsing error : " + e);
}
Observation: In your code Output = fm2.format(date) is being referenced.


Veteran Careers First
US
I was able to get it to work, thanks for your help.
But it seems to only work if I put the Julian Date numbers for ‘String Input’
If I try to pass a parameter it does not seem to take it.
Since the dates will change, how can I pass a value to ‘String Input’ instead of hardcode….
See Attachment
Accepted Solution


Pegasystems Inc.
US
To use the Parameter you should follow the below steps:
- Create a "Input" parameter in your activity of type String and INPUT.
- Replace your java code with below code,
String paramValue= (String) tools.getParameterPage().getParameterValue("Input");try{
java.text.DateFormat fmt1 = new java.text.SimpleDateFormat("yyyyDDD");
Date date = fmt1.parse(paramValue);
java.text.DateFormat fmt2 = new java.text.SimpleDateFormat("MM/dd/yyyy");
Output = fmt2.format(date);
}
catch(java.text.ParseException e){
oLog.info("Parsing error : " + e);
}
This way you can input the date value to your activity.
-
Satish Doppalapudi


Veteran Careers First
US
SO SO AWESOME!
It works perfectly!
Thank you very very much!


Pegasystems Inc.
US
You are welcome Henry:)
-
SWATHI DUVVALA Pravin Magar Ali Sabry Ashroff