Package com.spun.util
Class DateDifference
java.lang.Object
com.spun.util.DateDifference
public class DateDifference extends Object
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DateDifference(long timeDifference)DateDifference(Date date1, Date date2) -
Method Summary
Modifier and Type Method Description static intconvertUnitString(String unit)static longconvertUnitStringToMilli(String unit)longgetAbsoluteDifference(int unit)Gets the amount of [Units].static longgetAbsoluteDifference(int unit, long time)longgetAbsoluteDifference(String unit)StringgetClockTimeText()longgetRemainingDifference(int wantedUnit, int roundTo)Gets the remaining amount of [Units].static longgetRemainingDifference(int wantedUnit, int roundTo, long time)longgetRoundedDifference(int unit)static longgetRoundedDifference(int unit, long time)longgetRoundedDifference(String unit)longgetStandardRoundedTime(int unitIndex, boolean forceAbsolute)StringgetStandardTimeText(int amountShown)StringgetStandardTimeText(int amount, String maxUnit, String minUnit, String nowText, String agoText)static intgetTimeScaleIndex(int calendarTime)Finds the index for a Calendar.DATE ect.StringgetTimeText(int amount, int maxUnit, int minUnit, String nowText, String agoText, String[] units)booleanisMoreThan(int amount, int unit)booleanisMoreThan(int amount, String unitString)static voidprintDividers()Debugging tool.
-
Field Details
-
STANDARD_TIME_TEXT
-
MILLISECONDS
- See Also:
- Constant Field Values
-
SECONDS
- See Also:
- Constant Field Values
-
MINUTES
- See Also:
- Constant Field Values
-
HOURS
- See Also:
- Constant Field Values
-
DAYS
- See Also:
- Constant Field Values
-
WEEKS
- See Also:
- Constant Field Values
-
MONTHS
- See Also:
- Constant Field Values
-
YEARS
- See Also:
- Constant Field Values
-
TIME_UNITS
-
-
Constructor Details
-
DateDifference
public DateDifference(long timeDifference) -
DateDifference
-
-
Method Details
-
printDividers
public static void printDividers()Debugging tool. -
getAbsoluteDifference
public long getAbsoluteDifference(int unit)Gets the amount of [Units].
i.e.
Given a DateDifference of 2 Days 3 Hours 4 Minutes
getAbsoluteDifference(Calendar.DATE) = 2 getAbsoluteDifference(Calendar.HOUR) = 51 -
getAbsoluteDifference
-
getRoundedDifference
-
getRoundedDifference
public long getRoundedDifference(int unit) -
getAbsoluteDifference
public static long getAbsoluteDifference(int unit, long time) -
getRoundedDifference
public static long getRoundedDifference(int unit, long time) -
getRemainingDifference
public long getRemainingDifference(int wantedUnit, int roundTo)Gets the remaining amount of [Units].
i.e.
Given a DateDifference of 1 Month 2 Weeks 3 Days, getRemainingDifference(days, months) = 17 days
getRemainingDifference(days, weeks) = 3 days -
getRemainingDifference
public static long getRemainingDifference(int wantedUnit, int roundTo, long time) -
getTimeScaleIndex
public static int getTimeScaleIndex(int calendarTime)Finds the index for a Calendar.DATE ect.- Returns:
- the index in TIME_SCALE[]
-
convertUnitString
-
convertUnitStringToMilli
-
isMoreThan
public boolean isMoreThan(int amount, int unit) -
isMoreThan
-
getStandardRoundedTime
public long getStandardRoundedTime(int unitIndex, boolean forceAbsolute) -
getStandardTimeText
-
getTimeText
-
getClockTimeText
-
getStandardTimeText
-