When I log the query.toString(), I see that the issue created date is always 1 hour earlier than the one I see in the issue detail window. I would immediately doubt time zone, but I can’t understand why the application shows 18:46 but the query generated has 17:46 when they run on the same server. I mean, I upload the plugin to the jira application where the issue created date is always 1 hour later (in fact the application shows the correct time) than what issue.getCreated returns inside JQL. Do you have an idea?
The time printed by the plugin is the time in the server where the application is deployed. And the time shown in the application is the user’s timezone.
This can happen if your server is a Central Time but the user is in East Coast in the US.
@jobinkk, I’ve been struggling with this problem for a week now. But haven’t been able to find a solution to it. Both the server and user have the same time zone. It’s AZT +04. What I can’t understand is this: Why do I get the issue itself besides other ones from the above JQL? I clearly say that get me those that either have lower priority or have the same priority but created later than this one. Here’s the generated query:
{assignee = "mikola"} AND {resolution = "unresolved"} AND ( {priority < "High"} OR {priority = "High"} AND {created > "2017-03-27 17:46"} )
So, if this issue was created on “2017-03-27 17:46”, then why does the JQL include this issue in the result?
No. That’s not wrong. I need either lower priority ones or the ones that are the same priority and created later than this one. And that does what I need.
In fact, I had added those extra sub/endsub. But as AND operator is evaluated first, they’re redundant. If my memory serves me correctly, the the JQL ignored those extra brackets in the end and didn’t appear in the generated query.
Mikola, do you realize that the time zone setting can be defined differently for each user account?
Even if your JIRA has the default timezone X, a user may select timezone Y for himself, and I’d expect that ultimately the timezone of the user account on behalf the JQL is executed is the one that matters.
Ok, I finally solved the problem. As I was suspecting, the problem was caused by the fact that here, in Azerbaijan, we cancelled Day Light Saving in 2016. An the server had no patch for this case. Here are the steps I followed to get correct time zone information.
This returned “DayLight Saving 3600000”. It means I needed to apply the java patch
Calculated the SHA512. Go to the folder where you downloaded the tzdata file and run this command:
sha512sum tzdata2017c.tar.gz | cut -d’ ’ -f 1 > tzdata2017c.tar.gz.sha512.
Then run the below command
java -jar tzupdater.jar -v -l file:///<full_path>/tzdata2017c.tar.gz
Rerun the code in step 3. If it says “DayLight Saving: 0” – it means we’ve fixed it.
After this patching I get correct date/time in the server code.
And the problem regarding why the issue itself appeared in the list was because the JQL was omitting the part after minutes. So, although the issue was created on 2017-04-19 15:15:48.31, the JQL included only 2017-04-19 15:15 part.