1

With JIRA REST API there is at least 2 ways to get an issue:

  • /jira/rest/api/2/issue/{issueIdOrKey}
  • /rest/api/2/search?jql

I use both of them in my project but they return a slightly different results for updated field for the same issue.

  • Get by key: 2014-07-18T17:53:02.594+0300
  • Search: 2014-07-18T17:53:02.000+0300

By some reason milliseconds in search response are not set. It looks like a bug for me, but maybe there is configuration setting or something?

PS: I have the latest JIRA version (6.2.6)

2 Answers 2

1

JQL search results are generally fetched directly from the Lucene index, which stores timestamps with only millisecond resolution, whereas fetching the actual issue gets the date directly from the jiraissue table in the database, which can have sub-millisecond resolution (at least depending on your configured database).

EDITED: I see that I misread the precision above: the timestamp returned by getting the issue returns only milliseconds (vs nanoseconds) and the JQL query returns only integer seconds (vs milliseconds), so the Lucene data type linked above is not relevant.

However, the answer is still the same: JQL gets the result from Lucene, while an issue fetch gets the value directly from the database. On further investigation of why the Lucene index is not returning milliseconds: in the JIRA source in BaseFieldIndexer.indexDateField, JIRA calls LuceneUtils.dateToString(date) to convert the created field into a value that is indexable by Lucene. The dateToString method explicitly converts the field into an integer number of seconds (lopping off any milliseconds in the process), and it then converts the number to a String representation for indexing purposes.

Sign up to request clarification or add additional context in comments.

Comments

0

Odd! I checked this with a 6.2 instance and also got a difference:

JQL: updated: 2014-07-11T19:34:04.000-0500 Key: updated: 2014-07-11T19:34:04.768-0500

I bet the code that returns the list of issues from a search uses a different date formatter that clears the milliseconds, whereas the one that returns the data from a single issue doesn't do that. I don't know of any configuration setting that would affect that.

I recommend filing it as a minor bug at http://jira.atlassian.com/browse/JRA Minor because any code that is checking something based on ms seems unwise.

1 Comment

The problem is not with date formatter, but with how different JIRA databases save dates (check Scott's answer). It turns out that this bug was already reported.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.