Package com.spun.util
Class DateDifference
java.lang.Object
com.spun.util.DateDifference
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intconvertUnitString(String unit) static longlonggetAbsoluteDifference(int unit) Gets the amount of [Units].static longgetAbsoluteDifference(int unit, long time) longgetAbsoluteDifference(String unit) 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) getStandardTimeText(int amountShown) getStandardTimeText(int amount, String maxUnit, String minUnit, String nowText, String agoText) static intgetTimeScaleIndex(int calendarTime) Finds the index for a Calendar.DATE ect.getTimeText(int amount, int maxUnit, int minUnit, String nowText, String agoText, String[] units) booleanisMoreThan(int amount, int unit) booleanisMoreThan(int amount, String unitString) static voidDebugging tool.
-
Field Details
-
STANDARD_TIME_TEXT
-
MILLISECONDS
- See Also:
-
SECONDS
- See Also:
-
MINUTES
- See Also:
-
HOURS
- See Also:
-
DAYS
- See Also:
-
WEEKS
- See Also:
-
MONTHS
- See Also:
-
YEARS
- See Also:
-
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
-