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

How do I set a hard coded time with new date()?

I am trying to create a new issue using scriptrunner and I need to hard code the time on a custom date field. so I'd like it to have the current date with a time of 4:00 AM

I was hoping to use the new Date() function and then hard code the time to 4:00 AM instead of the current time.

def startTime = customFieldManager.getCustomFieldObjectByName("Start Time")

Date dateStart = new Date()

issue.setCustomFieldValue(startTime, new Timestamp(new Date().time))


The output of the customfield(Start Time) should be display  as follows dd/mm/yy 4:00 AM

1 answer

1 accepted

0 votes
Answer accepted

Jira stores all date/time fields in the db as timestamp values which are essentially the UTC EpochMilliseconds.

So that means that 4am for you may not be 4am for every user.

If you set the value to 4am server time, the equivalent UTC timestamp will be stored, and then other users in other timezones will see different times.

So depending on what you want and where you implement the script (i.e. who the script is running as) you might get different values.

If you don't care about all that and just want the current date at 4am (relative to the current user), just do this:

def dateStart = new Date().clearTime()
issue.setCustomFieldValue(startTime, dateStart)

I added the code above but I am getting the following error.


jira.workflow.WorkflowException: Java type java.util.Date not currently supported. Sorry.

Sorry, my bad

You need to convert the Date to a Timestamp before assigning it to a field:

issue.setCustomFieldValue(startTime, dateStart.toTimestamp())

Brilliant! that worked, thank you so much, really appreciate your help.

Suggest an answer

Log in or Sign up to answer

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