Package com.iizix.text.util
Class PrettyLocaledTexts
- java.lang.Object
- com.iizix.text.util.PrettyLocaledTexts
 
- public class PrettyLocaledTexts extends java.lang.ObjectUtility functions to produce locale'd strings for durations and distances.- Author:
- Christopher Mindus
 
- Constructor Summary- Constructors - Constructor - Description - PrettyLocaledTexts(ILocaleString localeString)Creates an instance of used for the application session and its locale.
 - Method Summary- All Methods Static Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - java.lang.String- decorateDistance(long distance, long here, int precision, int form)Gets the distance.- java.lang.String- decorateDuration(long duration, long now, int precision, int form)Gets the duration.- static PrettyLocaledTexts- getDefault()Gets the system default instance for PrettyLocaledTexts.- static void- main(java.lang.String[] args)
 
- Constructor Detail- PrettyLocaledTexts- public PrettyLocaledTexts(ILocaleString localeString) Creates 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 Detail- getDefault- public static PrettyLocaledTexts getDefault() Gets the system default instance for PrettyLocaledTexts.
 - decorateDuration- public java.lang.String decorateDuration(long duration, long now, int precision, int form)Gets 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.
- form- The form: 0=short, 1=medium, 2=long, 3=long with "one" as text.
- Returns:
- The locale'd string.
- Throws:
- java.lang.IllegalArgumentException- If the form is not 0-3 or precision not 0-3.
 
 - decorateDistance- public java.lang.String decorateDistance(long distance, long here, int precision, int form)Gets 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:
- java.lang.IllegalArgumentException- If the form is not 0-2.
 
 - main- public static void main(java.lang.String[] args)