get simple month year from custom date field

Tyler Siefring February 20, 2019

I want to capture just the month and year from a date picker field.  For example, I click on the field, in a date picker choose, 2/20/2019, and the field then stores Feb 2019.

 

As an alternative, I could leave that field as a date picker, then do a separate calculated field to get the MMM YYYY format.

I got this far...

import java.text.SimpleDateFormat
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Target Delivery Date")
def tcDate = issue.getCustomFieldValue(cf)

return new SimpleDateFormat("MMMM, yyyy", Locale.US).format(new Date(tcDate));

 

But get an error

groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.util.Date(java.sql.Timestamp)

 

Thanks for any help.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events