Configuring Jira's relative dates

In the Look and Feel documentation, it states that the date fields switch from relative to absolute after 1 week.  I would like to know if this could be configured to switch to absolute after 1 day instead of 1 week.  I will take any ideas.

1 answer

Hi Chris!

That's not actually an easy change, as the setting seems to be hard coded into JIRA's classes. However, you can  download the source code through My Atlassian (if you have a valid license for JIRA) and modify the class in which this appears to be setup, which is the com.atlassian.jira.datetime.DateTimeSettings, as shown below.

@Override
    public String format(DateTime dateTime, Locale locale)
    {
        DateTime now = new DateTime(clock.getCurrentDate(), dateTime.getZone());
        // fall back to complete dates if relative dates are disabled
        if (!isRelativeDateFormattingEnabled())
        {
            return completeFormatter.format(dateTime, locale);
        }
        // calculate the # of days between the start of each day. this should work with funky DST edge cases
        DateTime formatStartOfDay = new LocalDate(dateTime).toDateTimeAtStartOfDay();
        DateTime todayStartOfDay = new LocalDate(now).toDateTimeAtStartOfDay();
        int days = Days.daysBetween(formatStartOfDay, todayStartOfDay).getDays();
        //In the future
        if (days < 0)
        {
           return completeFormatter.format(dateTime, locale);
        }
        // today
        if (days < 1)
        {
            String todayFmt = serviceProvider.getUnescapedText("common.concepts.today");
            return new MessageFormat(todayFmt).format(new Object[] { timeFormatter.format(dateTime, locale) });
        }
        // yesterday
        if (days < 2)
        {
            String yesterdayFmt = serviceProvider.getUnescapedText("common.concepts.yesterday");
            return new MessageFormat(yesterdayFmt).format(new Object[] { timeFormatter.format(dateTime, locale) });
        }
        // last week
        if (days < 7)
        {
            String pattern = serviceProvider.getDefaultBackedString(APKeys.JIRA_LF_DATE_DAY);
            return jodaFormatterSupplier.get(new JodaFormatterSupplier.Key(pattern, locale)).print(dateTime);
        }
        // complete format
        return completeFormatter.format(dateTime, locale);
    }

--
Cheers!

Joao

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,861 views 12 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot