Class RelativeDateFormatter


  • public class RelativeDateFormatter
    extends java.lang.Object
    Formatter to format timestamps relative to the current time using time units in the format defined by git log --relative-date.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String format​(java.util.Date when)
      Get age of given Date compared to now formatted in the same relative format as returned by git log --relative-date
      private static long round​(long n, long unit)  
      private static long upperLimit​(long unit)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RelativeDateFormatter

        public RelativeDateFormatter()
    • Method Detail

      • format

        public static java.lang.String format​(java.util.Date when)
        Get age of given Date compared to now formatted in the same relative format as returned by git log --relative-date
        Parameters:
        when - Date to format
        Returns:
        age of given Date compared to now formatted in the same relative format as returned by git log --relative-date
      • upperLimit

        private static long upperLimit​(long unit)
      • round

        private static long round​(long n,
                                  long unit)