How can I get the Date Time of current logged in user and parse it

In case someone has the same issue in the future, this is the solution:

// Inject this
// import com.atlassian.jira.timezone.TimeZoneManager;

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");

// Get TimeZone of the current logged in user
TimeZone timeZone = timeZoneManager.getLoggedInUserTimeZone();

// Get the user's time
LocalDateTime usersTime = LocalDateTime.now(timeZone.toZoneId())

return formatter.format(usersTime);
1 Like