Getting different due date when invoking getDueDate

Please take a look at the following piece of code:

 1. public void setDueDate(MutableIssue issue, Timestamp dueDate){
 2.       System.out.println("Due date is " + dueDate);
 3.       issue.setDueDate(dueDate);
 4.       System.out.println("Due date set is " + issue.getDueDate());
 5.       issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false);
 6.       System.out.println("Reread set due date:"+issueManager.getIssueObject(issue.getId()).getDueDate());
 7.       JqlClauseBuilder builder= JqlQueryBuilder.newClauseBuilder();
 8.       Query query = builder.buildQuery();
 9.       PagerFilter pagerFilter = PagerFilter.getUnlimitedFilter();
 10.     SearchResults results = searchService.search(user, query, pagerFilter);
 11.     System.out.println("From JQL "+results.getIssues().get(0).getDueDate());
12.}

At line 2 I get Due date is 2017-06-02 00:00:00.0.
At line 4 I get Due date set is 2017-06-02 00:00:00.0
At line 6 I get Reread set due date:2017-06-02 00:00:00.0
At line 11 I get From JQL 2017-06-01 23:00:00.0

As you can see, in the last line, for some reason the due date shows 1 hour earlier, hence the previous day. I can’t understand why issue gotten from JQL shows different due date than that of retrieved though IssueManager. Do you have any idea?

1 Like

No, I don’t know the answer, but it’s a fun question, and I like that you posted a minimal sample that exposes the problem. I have a couple of observations:

a) the one-hour time difference may indicate a relationship to daylight saving. Is the date at line 11 always one hour out, or is it always returning the same value?

b) issue searches are performed against the Lucene database, and maybe it’s index hasn’t been updated.

Like I said, I don’t know the answer; just trying to seed your thinking.

1 Like

What time zone is your server in? Is it in a timezone with Daylight Savings Time? I would suggest adding in the Timezone as part of your output and see what it returns.

Do something like:

 1.  public void setDueDate(MutableIssue issue, Timestamp dueDate){
 2.      java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat( "yyyy.MM.dd G 'at' HH:mm:ss z" );
 2.       System.out.println("Due date is " + formatter.format(dueDate));
 3.       issue.setDueDate(dueDate);
 4.       System.out.println("Due date set is " + formatter.format( issue.getDueDate() ( );
 5.       issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false);
 6.       System.out.println("Reread set due date:"+  formatter.format( issueManager.getIssueObject(issue.getId()).getDueDate() ();
 7.       JqlClauseBuilder builder= JqlQueryBuilder.newClauseBuilder();
 8.       Query query = builder.buildQuery();
 9.       PagerFilter pagerFilter = PagerFilter.getUnlimitedFilter();
 10.     SearchResults results = searchService.search(user, query, pagerFilter);
 11.     System.out.println("From JQL "+  formatter.format( results.getIssues().get(0).getDueDate()) );
12.}
1 Like

@david.pinn ,there’s no daylight saving in that server. I always get one hour earlier than the actual date.

@daniel, here’s what I get with the formatter added.:

Due date is2017.06.02 AD at 00:00:00 AZT
Due date set is 2017.06.02 AD at 00:00:00 AZT
2017-06-02 00:00:00.0
Reread set due date:2017.06.02 AD at 00:00:00 AZT
From JQL 2017.06.01 AD at 23:00:00 AZT

The time zone is AZT. Just for reference, here in Azerbaijan we cancelled daylight saving last year. For that reason I’ve applied a patch to java in the server to reflect this change. I’ve explained in detail what I did in this post