I am working on a project and I want to create a script field to calculate the days elapsed up to the current date.
class Ejemplo {
public static void main(String[] args) {
def lastWeek = new Date() - 7;
def today = new Date()
println daysBetween(lastWeek, today)
}
static def daysBetween(def startDate, def currentDate) {
use(groovy.time.TimeCategory) {
def duration = currentDate - startDate
println "days: ${duration.days}"
return duration.days
}
}
}
I have advanced up here but I find myself stuck, I appreciate any help
Hi @Andres Martinez,
If you are trying to find the days of the issue b/w created and today you can use the below script in script field :)
import org.joda.time.Days
import org.joda.time.LocalDate
int days = Days.daysBetween(LocalDate.fromDateFields(issue.getCreated()), LocalDate.fromDateFields(new Date())).getDays()
Regards,
Leo
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.