Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 fetch the logged user timezone in groovy

I am trying to set the datetime field for an issue by picking the value from another issue.

Problem I am facing is that I am able to set the value but with different timezone. Is there any way I can set the time zone to the loggedin user.

I am trying with below code

import com.atlassian.jira.timezone.TimeZoneManager;
import java.util.TimeZone

TimeZone timeZone = timeZoneManager.getLoggedInUserTimeZone();



I am getting groovy.lang.MissingPropertyException: No such property: timeZoneManager for class


Can anyone help in resolving this

1 answer

1 accepted

1 vote
Answer accepted
/* -the old API has changed, 
regrettably this is an old question
but I hope my answer helps other people

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.timezone.TimeZoneManager

// -if you need the base TZ object

def userTimeZone = ComponentAccessor.getComponent(TimeZoneManager).getLoggedInUserTimeZone()

// -if you need the TZ string to pass to a date

def userTimeZoneValue = ComponentAccessor.getComponent(TimeZoneManager).getLoggedInUserTimeZone()

// -sample usage

def date = new Date().format('yyyy-MM-dd hh:mm:ss', TimeZone.getTimeZone(userTimeZoneValue))

// -check the output

return [userTimeZoneValue, date]

/* -this URL helped me

Thanks, that was helpful

Suggest an answer

Log in or Sign up to answer

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