How to get the day of week from date (ScriptRunner)

BarL October 15, 2019

Hello all,

I have the given script which returns the date of first transition to "In Progress":

package com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def created = changeHistoryManager.getChangeItemsForField(issue, "status").find {
it.toString == "In Progress"
}?.getCreated()

def createdTime = created?.getTime()

createdTime ? new Date(createdTime) : null

 

How to configure the script so it will return only the full day name for example : Monday

 

1 answer

1 accepted

1 vote
Answer accepted
Aleksandr Chuiko October 15, 2019

Hello! Try 

createdTime.toLocalDateTime().getDayOfWeek()

BarL October 15, 2019

Hi @Aleksandr Chuiko  , thanks for answering :) 

I am not sure where to put this line in the code?.. can you help me?

Aleksandr Chuiko October 15, 2019
Somehow so :)

package
com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def created = changeHistoryManager.getChangeItemsForField(issue, "status").find {
it.toString == "In Progress"
}?.getCreated()

def dayOfWeek = created?.toLocalDateTime()?.getDayOfWeek()

return dayOfWeek
BarL October 15, 2019

@Aleksandr Chuiko  Thanks! now I get the day name, but it returns the server machine time and not my local time (there is a gap of 10 hours between them). Do you know how to solve this?

Suggest an answer

Log in or Sign up to answer