Abstract
This code snippet adds a certain number of days to of minutes/hours/days/weeks/months to a Date/Date-Time picker field.
Logic
Access the Date/Date-Time picker field and add the number of days to it.Add the number of minutes/hours/days/weeks/months to the date field using Use(TimeCategory)
Snippet
Code Block | ||||
---|---|---|---|---|
| ||||
use (groovy.time.TimeCategory) { return <Date Object> + <Number of days> units>.<Unit> } |
Placeholders
Placeholder | Description | Example |
---|---|---|
<Date Object > | Access a date field | issue.get("created") |
<Number of days>units> | The number of days units to be added | 5 |
<Unit> | is one of "minutes","hours","days" "weeks" or "months" | months |
Examples
The output of this code snippet is a Timestamp which you could use in a Groovy expression, for example to:
Calculate and display Set a date field to issue created plus 5 days
Calculate and display aCode Block language groovy linenumbers true use (groovy.time.TimeCategory) { return issue.get("created") + 5
.days }
Set "Planned Delivery Date" as the 10 days 1 month from today
Code Block language groovy linenumbers true use (groovy.time.TimeCategory) { return new Date() + 1.month 10}
References
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...