com.atlassian.jira.util
Class JiraDurationUtils

java.lang.Object
  extended by com.atlassian.jira.util.JiraDurationUtils

public class JiraDurationUtils
extends Object

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  JiraDurationUtils.DurationFormatter formatter
          duration formatter currently in use
 
Constructor Summary
JiraDurationUtils(ApplicationProperties applicationProperties, JiraAuthenticationContext authenticationContext)
          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.
 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

FORMAT_PRETTY

public static final String FORMAT_PRETTY
pretty formatter aplication property value

See Also:
Constant Field Values

FORMAT_HOURS

public static final String FORMAT_HOURS
hours formatter application property value

See Also:
Constant Field Values

FORMAT_DAYS

public static final String FORMAT_DAYS
days formatter application property value

See Also:
Constant Field Values

formatter

protected JiraDurationUtils.DurationFormatter formatter
duration formatter currently in use

Constructor Detail

JiraDurationUtils

public JiraDurationUtils(ApplicationProperties applicationProperties,
                         JiraAuthenticationContext authenticationContext)
Sets the duration formatter based on the settings in the application properties and authentication context

Parameters:
applicationProperties - application properties
authenticationContext - authentication context
Method Detail

updateFormatters

public 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

Parameters:
applicationProperties - application properties
authenticationContext - authentication context

getI18nKey

public String getI18nKey()
Returns i18n resource key for the current formatter

Returns:
i18n resource key

getFormattedDuration

public String getFormattedDuration(Long duration)
Formats time duration with default (system) locale

Parameters:
duration - time duration to format
Returns:
formatted time duration

getFormattedDuration

public String getFormattedDuration(Long duration,
                                   Locale locale)
Formats time duration with given locale

Parameters:
duration - time duration to format
locale - user's locale
Returns:
formatted time duration

getShortFormattedDuration

public String getShortFormattedDuration(Long duration)
Formats time duration in the most compact way possible.

Parameters:
duration - time duration to format
Returns:
formatted time duration


Copyright © 2002-2009 Atlassian. All Rights Reserved.