Hi Community, I have a problem regarding with the datetime field . I am using two datetime custom field. I also use this scripted field by scriptrunner, but it returns an error
I used Date Time Range Picker as a Searcher and a Custom Template :
$datePickerFormatter.withStyle($dateTimeStyle.DATE).format($value)
code:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import java.util.Date.*
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def dateFieldObject= customFieldManager.getCustomFieldObject('customfield_10806');
def dateFieldObject2= customFieldManager.getCustomFieldObject('customfield_10807');
if(issue.getCustomFieldValue(dateFieldObject) && issue.getCustomFieldValue(dateFieldObject2)) {
def dateValue= issue.getCustomFieldValue(dateFieldObject) as Date
def dateValue2= issue.getCustomFieldValue(dateFieldObject2) as Date
return dateValue.getTime() - dateValue2.getTime() as Date
}
it says cannot return value of type long 2382000000 on method for java.util.Date. Thanks
Hello,
Difference between dates is not a date. It is a long value, which represents difference in milliseconds.
Hi @Alexey Matveev , how can I configure it to convert milliseconds on Day Hour Minute Format?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can. Have a look here:
Use the JiraDurationUtils:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using this one, can you help me?
java.util.concurrent.TimeUnit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Better use JiraDurationUtils. You can find an example here:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alexey Matveev , can you guide me on this one? I'm using this code but it goes under description. not on the date tabs
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import java.util.Date.*
import java.util.concurrent.TimeUnit
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def dateFieldObject= customFieldManager.getCustomFieldObject('customfield_10806');
def dateFieldObject2= customFieldManager.getCustomFieldObject('customfield_10807');
if(issue.getCustomFieldValue(dateFieldObject) && issue.getCustomFieldValue(dateFieldObject2)) {
def dateValue= issue.getCustomFieldValue(dateFieldObject) as Date
def dateValue2= issue.getCustomFieldValue(dateFieldObject2) as Date
def time = dateValue2.getTime() - dateValue.getTime()
long days = TimeUnit.MILLISECONDS.toDays(time);
long hours = TimeUnit.MILLISECONDS.toHours(time) % 24;
long minutes = TimeUnit.MILLISECONDS.toMinutes(time) % 60;
return String.format("%d Days %d Hours %d Minutes ", days, hours, minutes);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It can not go into the date tab, because it is not a date.
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.