|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.jira.util.JiraDurationUtils
public class JiraDurationUtils
Util class reponsible for printing durations in various formats.
Note that this class uses the Duration
formatting as configured for time-tracking and is therefore quite specific. For more generic duration formatting see
DateUtils
Nested Class Summary | |
---|---|
static class |
JiraDurationUtils.DaysDurationFormatter
This formatter formats time duration to days only. |
static interface |
JiraDurationUtils.DurationFormatter
This interface defines methods for formatting time duration |
static class |
JiraDurationUtils.HoursDurationFormatter
This formatter formats time duration to hours only. |
static class |
JiraDurationUtils.PrettyDurationFormatter
This formatter formats time duration to "pretty" format, such as 3 weeks, 2 days, 1 hour, 15 minutes. |
Field Summary | |
---|---|
static String |
FORMAT_DAYS
days formatter application property value |
static String |
FORMAT_HOURS
hours formatter application property value |
static String |
FORMAT_PRETTY
pretty formatter aplication property value |
protected com.atlassian.util.concurrent.ResettableLazyReference<JiraDurationUtils.DurationFormatter> |
formatterRef
duration formatter currently in use |
Constructor Summary | |
---|---|
JiraDurationUtils(ApplicationProperties applicationProperties,
JiraAuthenticationContext authenticationContext,
TimeTrackingConfiguration timeTrackingConfiguration,
com.atlassian.event.api.EventPublisher eventPublisher,
I18nHelper.BeanFactory i18nFactory)
Sets the duration formatter based on the settings in the application properties and authentication context |
Method Summary | |
---|---|
String |
getFormattedDuration(Long duration)
Formats time duration with default (system) locale |
String |
getFormattedDuration(Long duration,
Locale locale)
Formats time duration with given locale |
String |
getI18nKey()
Returns i18n resource key for the current formatter |
String |
getShortFormattedDuration(Long duration)
Formats time duration in the most compact way possible. |
String |
getShortFormattedDuration(Long duration,
Locale locale)
Formats time duration in the most compact way possible. |
void |
onClearCache(ClearCacheEvent event)
|
Long |
parseDuration(String duration)
Deprecated. since v4.4. Use parseDuration(String location, Locale locale) instead. |
Long |
parseDuration(String duration,
Locale locale)
Turn a duration string into the number of seconds that it represents, taking into account JIRA's configuration (i.e. |
void |
start()
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework. |
void |
updateFormatters(ApplicationProperties applicationProperties,
JiraAuthenticationContext authenticationContext)
Sets the duration formatter with a new instance of a particular formatter chosen based on the settings in the application properties and authentication context |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String FORMAT_PRETTY
public static final String FORMAT_HOURS
public static final String FORMAT_DAYS
protected com.atlassian.util.concurrent.ResettableLazyReference<JiraDurationUtils.DurationFormatter> formatterRef
Constructor Detail |
---|
public JiraDurationUtils(ApplicationProperties applicationProperties, JiraAuthenticationContext authenticationContext, TimeTrackingConfiguration timeTrackingConfiguration, com.atlassian.event.api.EventPublisher eventPublisher, I18nHelper.BeanFactory i18nFactory)
applicationProperties
- application propertiesauthenticationContext
- the context of the logged in user, used to get an I18nHelper appropriate for the
usertimeTrackingConfiguration
- the current time tracking configurationeventPublisher
- event publisher so the duration utils can be notified when an import occurs.i18nFactory
- the creator of i18nBean classes.Method Detail |
---|
public void start() throws Exception
Startable
start
in interface Startable
Exception
- Allows implementations to throw an Exception.@EventListener public void onClearCache(ClearCacheEvent event)
public void updateFormatters(ApplicationProperties applicationProperties, JiraAuthenticationContext authenticationContext)
applicationProperties
- application propertiesauthenticationContext
- authentication contextpublic String getI18nKey()
public String getFormattedDuration(Long duration)
duration
- time duration to format
public String getFormattedDuration(Long duration, Locale locale)
duration
- time duration to formatlocale
- user's locale
public String getShortFormattedDuration(Long duration)
duration
- time duration to format
public String getShortFormattedDuration(Long duration, Locale locale)
duration
- time in secondslocale
- locale to use. This is used only for translation, not for decimal formatting.
public Long parseDuration(String duration, Locale locale) throws com.atlassian.core.util.InvalidDurationException
duration
- string in JIRA's duration format (i.e. "20h")locale
- Locale to use when interpreting the duration string
com.atlassian.core.util.InvalidDurationException
- when the duration cannot be parsedpublic Long parseDuration(String duration) throws com.atlassian.core.util.InvalidDurationException
parseDuration(String location, Locale locale)
instead.
duration
- string in JIRA's duration format (i.e. "20h")
com.atlassian.core.util.InvalidDurationException
- when the duration cannot be parsed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |