Package com.spun.util

Class DateDifference

java.lang.Object
com.spun.util.DateDifference

public class DateDifference extends Object
  • Field Details

  • Constructor Details

    • DateDifference

      public DateDifference(long timeDifference)
    • DateDifference

      public DateDifference(Date date1, Date date2)
  • 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

      public long getAbsoluteDifference(String unit)
    • getRoundedDifference

      public long getRoundedDifference(String unit)
    • 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

      public static int convertUnitString(String unit)
    • convertUnitStringToMilli

      public static long convertUnitStringToMilli(String unit)
    • isMoreThan

      public boolean isMoreThan(int amount, int unit)
    • isMoreThan

      public boolean isMoreThan(int amount, String unitString)
    • getStandardRoundedTime

      public long getStandardRoundedTime(int unitIndex, boolean forceAbsolute)
    • getStandardTimeText

      public String getStandardTimeText(int amount, String maxUnit, String minUnit, String nowText, String agoText)
    • getTimeText

      public String getTimeText(int amount, int maxUnit, int minUnit, String nowText, String agoText, String[] units)
    • getClockTimeText

      public String getClockTimeText()
    • getStandardTimeText

      public String getStandardTimeText(int amountShown)