Package com.ibm.icu.impl.duration
Interface PeriodBuilderFactory
- All Known Implementing Classes:
BasicPeriodBuilderFactory
public interface PeriodBuilderFactory
-
Method Summary
Modifier and TypeMethodDescriptiongetFixedUnitBuilder
(TimeUnit unit) Returns a builder that represents durations in terms of the single given TimeUnit.getMultiUnitBuilder
(int unitCount) Returns a builder that formats up to the given number of time units, starting with the largest unit less than or equal to the duration.Returns a builder that formats the largest one or two time units, starting with the largest period less than or equal to the duration.Returns a builder that represents durations in terms of the single largest period less than or equal to the duration.setAllowMilliseconds
(boolean allow) Sets whether milliseconds are allowed.setAllowZero
(boolean allow) Sets whether units with a value of zero are represented in a period when 'gaps' appear between time units, e.g.setAvailableUnitRange
(TimeUnit minUnit, TimeUnit maxUnit) Sets the time units available for use.Sets the locale for the factory.setMaxLimit
(float maxLimit) Sets the maximum value for the largest available time unit (as set in setUnits).setMinLimit
(float minLimit) Sets the minimum value for the smallest available time unit (as set in setUnits).setTimeZone
(TimeZone timeZone) Sets the time zone for the factory.setUnitIsAvailable
(TimeUnit unit, boolean available) Sets whether the time unit is available for use.setWeeksAloneOnly
(boolean aloneOnly) Sets whether weeks are used with other units, or only when weeks are the only unit.
-
Method Details
-
setAvailableUnitRange
Sets the time units available for use. Default is all units.- Parameters:
minUnit
- the smallest time unit available for usemaxUnit
- the largest time unit available for use- Returns:
- this factory
-
setUnitIsAvailable
Sets whether the time unit is available for use.- Parameters:
unit
- the time unitavailable
- true if the unit is available for use- Returns:
- this factory
-
setMaxLimit
Sets the maximum value for the largest available time unit (as set in setUnits). Periods that represent a longer duration than this will be pinned to this value of that time unit and return true for 'isMoreThan'. Default is no limit. Setting a value of zero restores the default. -
setMinLimit
Sets the minimum value for the smallest available time unit (as set in setUnits). Periods that represent a shorter duration than this will be pinned to this value of that time unit and return true for 'isLessThan'. Default is no limit. Setting a value of zero restores the default. -
setAllowZero
Sets whether units with a value of zero are represented in a period when 'gaps' appear between time units, e.g. '2 hours, 0 minutes, and 33 seconds'. Default is to not represent these explicitly ('2 hours and 33 seconds'). -
setWeeksAloneOnly
Sets whether weeks are used with other units, or only when weeks are the only unit. For example '3 weeks and 2 days' versus '23 days'. Default is to use them alone only. -
setAllowMilliseconds
Sets whether milliseconds are allowed. This is only examined when milliseconds are an available field. The default is to allow milliseconds to display normally.This is intended to be used to set locale-specific behavior. Typically clients will not call this API and instead call
setLocale(java.lang.String)
.- Parameters:
allow
- whether milliseconds should be allowed.- Returns:
- a builder
-
setLocale
Sets the locale for the factory. Setting the locale can adjust the values for some or all of the other properties to reflect language or cultural conventions. Default is to use the default locale. -
setTimeZone
Sets the time zone for the factory. This can affect the timezone used for date computations.- Parameters:
timeZone
- the timeZone- Returns:
- a builder
-
getFixedUnitBuilder
Returns a builder that represents durations in terms of the single given TimeUnit. If the factory settings don't make the given unit available, this will return null.- Parameters:
unit
- the single TimeUnit with which to represent times- Returns:
- a builder
-
getSingleUnitBuilder
PeriodBuilder getSingleUnitBuilder()Returns a builder that represents durations in terms of the single largest period less than or equal to the duration.- Returns:
- a builder
-
getOneOrTwoUnitBuilder
PeriodBuilder getOneOrTwoUnitBuilder()Returns a builder that formats the largest one or two time units, starting with the largest period less than or equal to the duration. It formats two periods if the first period has a count < 2 and the next period has a count >= 1.- Returns:
- a builder
-
getMultiUnitBuilder
Returns a builder that formats up to the given number of time units, starting with the largest unit less than or equal to the duration.- Returns:
- a builder
-