Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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

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 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

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

Atlassian Community Events