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

Get DateTime CustomField Value

Hi Atlassians,

How to get DateTime CustomField Value of a specified issue?

My code is the following:

log.debug("get datetime customField Value: " + issue.getCustomFieldValue(customField_X).toString());

Did I miss something?



2 answers

looks nice. What is customField_X? how do you get that variable? Are you sure there is something inside that issue? can you get other custom field values using that code?

Hi Alexey,

I got that variable like this:

CustomField customField_X= customFieldManager.getCustomFieldObject(111);

where 111 is the ID of a Date/Time customField. I got the value of the custom field (Text Field) using that code.I should use a specific code for the DateTime field?



I don't remember I've got some problem with getting of date fields. Could you please modify your code to

log.debug("get datetime customField class: " + issue.getCustomFieldValue(customField_X).getClass().toString());

and give the output generated? Do you see at least the message "get datetime customField Value: "

Thanks Alexey, you are right, the output is: class java.sql.Timestamp. How should I convert it in order to get the value?

Many thanks,


Timestamp stamp = new Timestamp(System.currentTimeMillis());
Date date = new Date(stamp.getTime());
0 votes

getCustomFieldValue(customField_X) is going to return the object that is in the field. For many types of object that get stored in fields, .toString() will give you something you can quite easily read and use.

But date and date/time fields return objects (Timestamps, if memory serves) which do NOT implement a .toString() that returns anything that's much use to a human.

You'll need to delve further into the object it does return to work out what you can use. Alexey's code will at least tell you the name of the class you need to work with!

As I remember it is Timestamp definitely. But I don't remember that it doesn't implement toString() method (I mean implements empty string) - as for the reference implementation exists

Hello again,

I used getValue instead of getCustomFieldValue(customField_X):

log.debug( "customField_X.getValue()" + customField_X.getValue(issue).toString());

and I obtained 2014-07-09 15:49:00.0 for example, now I will try to convert it into the format that I need , but at least, I got the value.

Thanks all,


Hi all,

I sucessfully get the Date/Time Value of the CustomField using the following code:

public String getCustomFieldStringValue(Issue issue, CustomField customField) throws Exception {

String customFieldStringValue = "";

Object value = issue.getCustomFieldValue(customField);

if(value instanceof java.sql.Timestamp) {

DateFormat fullDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS");

DateFormat dateFormatWithoutSeconds = new SimpleDateFormat("yyyy-MM-dd HH:mm");

Date date = fullDateFormat.parse(customField.getValue(issue).toString());

customFieldStringValue = dateFormatWithoutSeconds.format(date);


log.debug("Custom Field " + customField.getName() + " has the following string value: " + customFieldStringValue);

return customFieldStringValue;


But, I'm still facing a problem with the Time Zone.

The value displayed is related to the Time Zone of the Server, however, I should obtain the value related to the Time Zone of the Client. For example, my server is in Paris and I'm using my plugin from Beirut = > The above code gives me the time related to Paris.

How to get the time depending of the time zone of the connected user, not the server where installed Jira?



Hello @Rosy Salameh - perhaps this comes too late :-)

Have you tried:

def userTimeZoneValue = ComponentAccessor.getComponentOfType(TimeZoneManager.class).getLoggedInUserTimeZone().getProperties()['lastRule'].getProperties()['ID'].toString()


someDate.format('dd/MMM/yy HH:mm',TimeZone.getTimeZone(userTimeZoneValue))

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