Package org.eclipse.jgit.util
Class RelativeDateFormatter
- java.lang.Object
-
- org.eclipse.jgit.util.RelativeDateFormatter
-
public class RelativeDateFormatter extends java.lang.Object
Formatter to format timestamps relative to the current time using time units in the format defined bygit log --relative-date
.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static long
DAY_IN_MILLIS
(package private) static long
HOUR_IN_MILLIS
(package private) static long
MINUTE_IN_MILLIS
(package private) static long
MONTH_IN_MILLIS
(package private) static long
SECOND_IN_MILLIS
(package private) static long
WEEK_IN_MILLIS
(package private) static long
YEAR_IN_MILLIS
-
Constructor Summary
Constructors Constructor Description RelativeDateFormatter()
-
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 givenDate
compared to now formatted in the same relative format as returned bygit log --relative-date
private static long
round(long n, long unit)
private static long
upperLimit(long unit)
-
-
-
Field Detail
-
SECOND_IN_MILLIS
static final long SECOND_IN_MILLIS
- See Also:
- Constant Field Values
-
MINUTE_IN_MILLIS
static final long MINUTE_IN_MILLIS
- See Also:
- Constant Field Values
-
HOUR_IN_MILLIS
static final long HOUR_IN_MILLIS
- See Also:
- Constant Field Values
-
DAY_IN_MILLIS
static final long DAY_IN_MILLIS
- See Also:
- Constant Field Values
-
WEEK_IN_MILLIS
static final long WEEK_IN_MILLIS
- See Also:
- Constant Field Values
-
MONTH_IN_MILLIS
static final long MONTH_IN_MILLIS
- See Also:
- Constant Field Values
-
YEAR_IN_MILLIS
static final long YEAR_IN_MILLIS
- See Also:
- Constant Field Values
-
-
Method Detail
-
format
public static java.lang.String format(java.util.Date when)
Get age of givenDate
compared to now formatted in the same relative format as returned bygit log --relative-date
- Parameters:
when
-Date
to format- Returns:
- age of given
Date
compared to now formatted in the same relative format as returned bygit log --relative-date
-
upperLimit
private static long upperLimit(long unit)
-
round
private static long round(long n, long unit)
-
-