...
title | Date format |
---|
ISO formatted date
Code Block | ||
---|---|---|
| ||
import java.text.SimpleDateFormat
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd")
def today = format.format( new Date() ) |
RFC3339 date
...
Code Block | ||
---|---|---|
| ||
import java.text.SimpleDateFormat
//2020-10-03T10:00:00Z
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
def today = format.format( new Date() ) |
...
Add 10 minutes
Code Block |
---|
import java.text.SimpleDateFormat
import groovy.time.TimeCategory
//2020-10-03T10:00:00Z
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
def currentDate = new Date()
def after30Mins
use( TimeCategory ) {
after30Mins = currentDate + 10.minutes
}
def today = format.format(after30Mins) |
Subtract 10 minutes
Code Block |
---|
import java.text.SimpleDateFormat
import groovy.time.TimeCategory
//2020-10-03T10:00:00Z
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
def currentDate = new Date()
def after30Mins
use( TimeCategory ) {
after30Mins = currentDate - 10.minutes
}
def today = format.format(after30Mins) |
more options on time are:
x.weeks
x.months
x.seconds
ref https://docs.groovy-lang.org/latest/html/api/groovy/time/TimeCategory.html
...
Extract insight key from custom field value.
When you do a GET on an issue containing insight custom field value it will return an array of values like this [“My object (thekey-123)“,”My other object (thekey-456)”] to extract the key from that use a groovy variable with the lines below. It will return thekey-123 and thekey-456
Code Block |
---|
def regexp = /\(([^\)]+)\)/
def matcher = response =~ regexp
return matcher.getAt(0)[1] |