Package com.iizix.text.util
Class PrettyLocaledTexts
java.lang.Object
com.iizix.text.util.PrettyLocaledTexts
Utility functions to produce locale'd strings for durations and distances.
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescription- PrettyLocaledTexts- (ILocaleString localeString) Creates an instance of used for the application session and its locale.
- Method SummaryModifier and TypeMethodDescription- decorateDistance- (long distance, long here, int precision, int form) Gets the distance.- decorateDuration- (long duration, long now, int precision, int form) Gets the duration.- static PrettyLocaledTextsGets the system default instance for PrettyLocaledTexts.
- Constructor Details- PrettyLocaledTextsCreates an instance of used for the application session and its locale. If the locale is changed, a new instance of this class should be retrieved.- Parameters:
- localeString- The locale string instance, null for system default.
 
 
- Method Details- getDefaultGets the system default instance for PrettyLocaledTexts.
- decorateDurationGets the duration.- Parameters:
- duration- The duration in seconds (absolute value is used).
- now- The amount of seconds considered as "now".
- precision- 0=seconds, 1=minutes, 2=hours, 3=days, 4=weeks, 5=years (of 365 days)
- form- The form: 0=short, 1=medium, 2=long, 3=long with "one" as text.
- Returns:
- The locale'd string.
- Throws:
- IllegalArgumentException- If the- precisionnot 0-5 or- formis not 0-3.
 
- decorateDistanceGets the distance.- If the distance is less than "here", "near" or "close by" is always returned, regardless of precision. - If precision is 1=kilometer and the distance is less than 1000, "less than a kilometer" is returned. - Parameters:
- distance- The distance in meters (absolute value is used).
- here- The amount of meters considered as "here" or "nearby".
- precision- Precision: 0=meters, 1=kilometers.
- form- The form: 0=short, 1=long, 2=long with "one" as text.
- Returns:
- The locale'd string.
- Throws:
- IllegalArgumentException- If the- precisionis not 0-1 or- formis not 0-2.