Uploaded image for project: 'SR for Jira - Development'
  1. SR for Jira - Development
  2. SRJIRA-1187

Date Picker Custom field with Script Runner

    Details

    • Type: Change
    • Status: To Do
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Environment:

      Dev

    • Critical Points:
      0

      Description

      I have created a Date picker custom field ( cf2) which return cf2 = cf1 + 1 Day,
      where cf1 is an existing customfield.
      Is there anyone can help me remove the Times tamp on my return. Currently cf2 is showing as " MM/dd/yyyy hh:mm a " and i will like to get " MM/dd/yyyy " this format instead.
      I am not good in Groovy nor Java, but here's a glance of my code below.
      It's working, but i just need help to remove the time stamp w/o going to the Look and Field in Admin and change the Date/Time Formats.

      Thanks!

      def componentManager = ComponentManager.getInstance()
      def customFieldManager = componentManager.getCustomFieldManager()

      CustomField field1 = customFieldManager.getCustomFieldObject(new Long(XXXXX)); //Initial field cf1
      CustomField resultField = customFieldManager.getCustomFieldObject(new Long(YYYY)); //NEW FIELD cf2

      def field1value = issue.getCustomFieldValue(field1);

      if (field1value != null )
      {
      //Calendar cal = Calendar.getInstance();
      //cal.setTime(field1value);
      //cal.add(Calendar.DATE,1);//add 1 day
      //DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
      //formatter = new SimpleDateFormat("MM/dd/yyyy");

      //result = df.format(field1value + 1).toString();

      //result = format1.format(cal.getTime());
      result = field1value + 1 ;

      }
      else
      {
      result = null;

        Attachments

          Activity

            People

            Assignee:
            jechlin Jamie Echlin
            Reporter:
            DanTogo Dan Mak
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: