Set field value : Is there way to get only the time value from date time picker custom field?

Hello,

 

I am using set field value (from groovy expression) post function. 

My requirement is to update a select list field (with options shift 1 m, shift 2, shift 3 etc) based on the "hour" value which should be extracted from custom field date time picker type. 

I use the groovy expression : 

issue.getAsString("Begin Date")

which is giving complete timestamp including date as shown in screenshot below: 

timevalue.pngCan i extract only the time value? 

I appended getTimeString() to the above code but it doesnt seem to work.

 

Any help?

 

Thanks!

Swathi

1 answer

1 accepted

0 vote

Hi,

you can use all the methods of the Date class on the result of issue.get("Begin Date"): https://docs.oracle.com/javase/7/docs/api/java/util/Date.html

For example, to get the hours:

issue.get("Begin Date").getHours()

 Note that Java doesn't have a class to represent just a time value (without a date), so you'll have to manipulate the hours, minutes and seconds as numbers.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

72 views 0 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you