Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
languagejs
linenumberstrue
use (groovy.time.TimeCategory) {
     return <Date Object> + <Number of days> units>.<Unit>
 }

Placeholders

PlaceholderDescriptionExample
<Date Object>Access a date fieldissue.get("created")
<Number of days>units>
The number of days units to be added5
<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

    Code Block
    languagegroovy
    linenumberstrue
    use (groovy.time.TimeCategory) {
         return issue.get("created") + 5
    Calculate and display a
    .days
     }


  • Set "Planned Delivery Date" as the 10 days 1 month from today

    Code Block
    languagegroovy
    linenumberstrue
    use (groovy.time.TimeCategory) {
         return new Date() + 1.month
     10}


References

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "jmwe-groovy" and type = "page" and space = "JMWE"
labelsjmwe-nunjucks jmwe-cloud

...