AnsweredAssumed Answered

Increment DateTime by Interval in Minutes

Question asked by milowski@ohsu.edu on Aug 6, 2018
Latest reply on Aug 7, 2018 by Sjaak Overgaauw

I have a need to store the "current date" in persistent PP_START, increment it by number of minutes and store it in PP_END persistent property.

Does anyone can suggest the best approach? I already have a custom Groovy script function which allows me to increments/decrements a date by a number of days. I just need more precise date/time manipulation.

 

 

Here is the content of the current Groovy script:

 

import java.util.GregorianCalendar;
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat

String dt = date;
int n = increment;
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
Calendar c = Calendar.getInstance();
c.setTime(sdf.parse(dt));
c.add(Calendar.DATE, n); // number of days to add
dateOUT = sdf.format(c.getTime()); // dt is now the new date

Outcomes