I have this simple example Script Field (using the Date template) that returns a date value:
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
String dateString = "2020-01-01"
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
try {
// Parse the date string into a Date object
Date date = formatter.parse(dateString);
return date
} catch (ParseException e) {
log.error("Unable to parse date value on issue")
}
It returns 2020-01-01 as expected. The field is configured with a Date Time Range Searcher (which is the only date searcher available).
JQL works when I do:
MyDate = 2020-01-01
But it doesn't work for users in a different timezone. Users in a different timezone must use MyDate >= 2020-01-01 for example.
So it seems like Jira is somehow factoring in the timestamp internally.
How can I get it to behave like the internal Due Date, or other regular Date fields?
I think the problem is that Script Runner's fields do not have a *Date Range Searcher* available.
Hi @David Yu
Firstly, I would like to clarify, when you use the Scripted Field in your JQL Query, are you also displaying it in the result? If yes, this can cause other issues in your environment.
Next, have you tried looking into the LocalDate class instead of just using Date?
I am looking forward to your feedback and clarification.
Thank you and Kind regards,
Ram
Ram, ScriptRunner does a type check it seems and refuses to let you return a LocalDate object.
Anyway, I think this is related to the Searcher ScriptRunner uses. If ScriptRunner supported *Date Range Searcher* in addition to *Date Time Range Searcher*, these problems would go away.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.