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

Velcotiy redering the date field incorrect upon changing the user timezone

Naren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2014

Hi,

My JIRA Server's default TimeZone is (GMT-06.00) Chicago. A user located in a different geographic location sets his user profile to different TZ, say, America -> Denver. My JIRA Server uses UTC time.

We've 2 date picker customfields in JIRA that provide a date range. When user changes his TZ to his local TZ (other than JIRA Server's default TZ) and sets the value of these date picker customfields to current date 14/Jul/14, the velocity code dealing with these customfields outputs 13/Ju/14. Below is the velocity code -


#set($serviceStartDateId = 'customfield_10702')
#set($serviceStartDateField = $customFieldManager.getCustomFieldObject($serviceStartDateId))
        
#set($serviceStopDateId = 'customfield_10703')
#set($serviceStopDateField = $customFieldManager.getCustomFieldObject($serviceStopDateId))
				
#if($issue.getCustomFieldValue($serviceStartDateField) && $issue.getCustomFieldValue($serviceStopDateField))
                                        
#set($serviceStartDateFieldValue = "")
#set($serviceStartDateFieldValue = $issue.getCustomFieldValue($serviceStartDateField))
#set($serviceStopDateFieldValue = "")
#set($serviceStopDateFieldValue = $issue.getCustomFieldValue($serviceStopDateField))
                                            
#set($serviceStartFormatDMY = $outlookdate.formatDMY($serviceStartDateFieldValue))
#set($serviceStopFormatDMY = $outlookdate.formatDMY($serviceStopDateFieldValue))

How can the date entered in the date picker customfield be rendered as is i.e., 14/Jul/14 and not 13/Jul/14. This is creating problems in further code which pulls information based on the date picker field's value.

Any help is much appreciated.

Thanks,

Naren.

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
KAORU FUJII June 25, 2015

Dear Naren,

I'm stuck with the same issue as you.

If you have already find the solution, could you please share it with me?

 

Best Regards,

Masaya

0 votes
Naren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2014

Upon debugging the velocity code, I found following -

After setting the TZ to the local TZ and updating the date picker custom fields to the current date - 14/Ju/14. JIRA displays the dates properly. Also in the above velocity code, the $serviceStartDateFieldValue and $serviceStopDateFieldValue outputs the values properly in i.e., 2014-07-14 00:00:00.0.

However, the below 2 lines changes the date to the TZ in which the current user is logged in -

#set($serviceStartFormatDMY = $outlookdate.formatDMY($serviceStartDateFieldValue)) 

#set($serviceStopFormatDMY = $outlookdate.formatDMY($serviceStopDateFieldValue))

The $outlookdate.formatDMY seems to be rendering the TZ to the currently logged in user's TZ. I'm exploring further if we can render the date picker values in velocity, as is, irrespective of change in the user's TZ.

TAGS
AUG Leaders

Atlassian Community Events