Package eu.woolplatform.utils.schedule
Class DateUnit
- java.lang.Object
-
- eu.woolplatform.utils.schedule.DateUnit
-
public class DateUnit extends Object
A date unit is a unit for durations that span one or more days. The known date units are defined as constants of this class.- See Also:
DateDuration
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DateUnit[]getDateUnits(DateUnit min, DateUnit max)Returns the known date units between the specified smallest and largest date unit.StringgetDurationString(int n)Returns a date duration string for the specified number of this date unit.static DateUnitparse(String s, DateUnit min, DateUnit max)Parses a date unit string.StringtoString()
-
-
-
Method Detail
-
getDurationString
public String getDurationString(int n)
Returns a date duration string for the specified number of this date unit. For example, if this date unit isMONTHand you setnto 3, this method will return "3 months".- Parameters:
n- the number of date units- Returns:
- the date duration string
-
parse
public static DateUnit parse(String s, DateUnit min, DateUnit max) throws IllegalArgumentException
Parses a date unit string. The string can be a singular or plural form of the date unit. You can specify the smallest and largest allowed date unit.- Parameters:
s- the stringmin- the smallest allowed date unit. You can set this to null for the smallest known date unit.max- the largest allowed date unit. You can set this to null for the largest known date unit.- Returns:
- the date unit
- Throws:
IllegalArgumentException- if the string is invalid
-
getDateUnits
public static DateUnit[] getDateUnits(DateUnit min, DateUnit max)
Returns the known date units between the specified smallest and largest date unit.- Parameters:
min- the smallest date unit to return. You can set this to null for the smallest known date unit.max- the largest date unit to return. You can set this to null for the largest known date unit.- Returns:
- the date units
-
-