Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Convert Milliseconds to Day Hours Min Format using Scripted Field

Hi All, I have 2 custom field date-time picker, and I want to get the difference of them using scripted field, but my field returns milliseconds. How can I convert it to days hours using:

Search Template : Duration Picker or Date Time Range Picker

Template : Custom ,

code : $datePickerFormatter.withStyle($dateTimeStyle.DATE).format($value)


script -->

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

1 answer

1 vote

Hello @Alvin Parreno

In your code the statement

dateValue.getTime() - dateValue2.getTime()

returns long value and you are trying to cast it to "Date" thus you see this error.

Instead you should return

return new Date(dateValue.getTime() - dateValue2.getTime())

Hi @Tarun Sapra , thank you for a quick response . Can you check this out, I configured my code based on your suggestion but it returns like this:

Description :

Screenshot from 2018-10-02 09_49_03.png



 Screenshot from 2018-10-02 09_48_44.png

I need to return it something like XX Days XX Hours XX Mins, can you help me out? Thanks!

Tarun Sapra Community Leader Oct 02, 2018

Hello, @Alvin Parreno in order to return the value in days, hours etc, it's possible to do that. Just use JiraDurationUtils.

Hi @Tarun Sapra , I already managed to do that, but it is visible on Description Tab. not on the Dates Tab, how can I fix that?

Tarun Sapra Community Leader Oct 02, 2018

Hello @Alvin Parreno

In the custom template, use the following snippet


And from your script return (i.e. returned value should be long) which is passed to jira duration utils.

return dateValue.getTime() - dateValue2.getTime()

Suggest an answer

Log in or Sign up to answer
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

76 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you