Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

Abstract

This code snippet fetches the current user time zone.

Logic

Fetch Access the Time zone component service of Jira and create a Calendar instance with this fetch the logged in user time zone.

Snippet

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

// access timeZone of current user

def userTimeZone = getComponent(TimeZoneManager).getLoggedInUserTimeZone()
c1 = GregorianCalendar.getInstance(userTimeZone);

Placeholders

NA

Examples

The outcome of the code snippet is a zoneInfo that you can use to create a calendar instance

...

in the current user time zone

...

and format a date.

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

// access timeZone of current user
def userTimeZone = getComponent(TimeZoneManager).getLoggedInUserTimeZone()
c1 = GregorianCalendar.getInstance(userTimeZone);
return c1.format("HH:mm")

References

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "jmwe-groovy" and type = "page" and space = "KB"
labelsjmwe-nunjucks jmwe-cloud

...