It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

Hello! Try 

createdTime.toLocalDateTime().getDayOfWeek()

Hi @Aleksandr Chuiko  , thanks for answering :) 

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

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

@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
Community showcase
Published in Jira

The add-in you’ve been waiting for: Jira Cloud for Excel 🙌

Introducing Jira Cloud for Excel Here at the product integrations team at Atlassian, we are thrilled to announce the new Jira Cloud for Excel add-in! This add-in lets you export Jira data directly ...

864 views 6 24
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you