How do I get the values from Date/Time Formats"?

Sergio Deras March 28, 2013

Hello:

I am working with a plug-in and I need to get the value of the Date/Time Formats that can be configured in the System-Look and Feel Configuration.

I cannot find any refernece in the web to get this.

I have tried :
com.atlassian.jira.config.properties.ApplicationProperties applicationProperties= getApplicationProperties();

1. applicationProperties.getText("jira.date.picker.java.format");
2. applicationProperties().getString("jira.date.picker.java.format");
3. applicationProperties().getStringsWithPrefix("jira.date");
4. applicationProperties().getDefaultBackedString("jira.date.picker.java.format");
5. applicationProperties().getDefaultString("jira.date.time.picker.java.format");


1. and 2. retun Null
3. returns an empty Collection
4. returns "d/MMM/yy", it looks like this is the default, but I have changed this property in the Jira Look and Feel page to "dd/MM/yyyy"
5. again, this looks like the defaul value "dd/MMM/yy h:mm a", I have setup this one as "dd/MM/yyyy h:mm a"

How can I get the value from the system please?

5 answers

1 accepted

3 votes
Answer accepted
Sergio Deras April 1, 2013

The answer in this example:

public String getJiraDateFormat(ApplicationProperties applicationProperties) {
String format = applicationProperties.getDefaultBackedString(APKeys.JIRA_LF_DATE_DMY);
return format;
}

The property that I needed was

"jira.lf.date.dmy" , that is APKeys.JIRA_LF_DATE_DMY
IshanL
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 2, 2013

Thanks @Sergio for the answer

1 vote
Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 28, 2013

This code will help you , I think you are looking for the same.

private String getOriginalEstimateString(Issue issue)

{

long estimate = -1;


if (issue != null)

{

if (issue.getEstimate() != null && issue.getOriginalEstimate() != null)

{

estimate = Math.min(issue.getOriginalEstimate().longValue(), issue.getEstimate().longValue());

}


if (estimate != -1)

{

return DateUtils.getDurationString(estimate, getHoursPerDay(), getDaysPerWeek());

}

}


return null;


}

private int getHoursPerDay()

{

return Integer.parseInt(ComponentAccessor.getApplicationProperties().getDefaultBackedString(APKeys.JIRA_TIMETRACKING_HOURS_PER_DAY));

}

private int getDaysPerWeek()

{

return Integer.parseInt(ComponentAccessor.getApplicationProperties().getDefaultBackedString(APKeys.JIRA_TIMETRACKING_DAYS_PER_WEEK));

}

0 votes
Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 28, 2013

if you are writing plugin for datepicker or date and time picker then you should try this location WEB-INF\classes\jira-application.properties to change date format.

0 votes
Sergio Deras March 28, 2013

Would it be a way to get the value from the Look And Feel? Instead from the Advanced Settings?

0 votes
Sergio Deras March 28, 2013

So it looks like the Look And Feel just work for the Jira specific server, for my plug-in I need to modify the values in

"<JiraContext>/admin/AdvancedApplicationProperties.jspa"

Then applicationProperties().getDefaultBackedString("jira.date.picker.java.format");

returns the value that I have set.

Onkar Ahire
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 28, 2013

above code was just an example which retrive the values i.e. 1day 2 hours 30 mins like that.

Sergio Deras March 28, 2013

Thanks Onkar I have just seen your answer.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events