Top Description Fields Constructors Methods
org.eclipse.jgit.util

public Class RelativeDateFormatter

extends Object
Class Inheritance
Imports
java.text.MessageFormat, java.time.Duration, .Instant, java.util.Date, org.eclipse.jgit.internal.JGitText

Formatter to format timestamps relative to the current time using time units in the format defined by git log --relative-date.

Field Summary

Modifier and TypeField and Description
pack-priv static final long
pack-priv static final long
pack-priv static final long
pack-priv static final long
pack-priv static final long
pack-priv static final long
pack-priv static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

age of given java.util.Date compared to now formatted in the same relative format as returned by git log --relative-date
format
(Date
java.util.Date to format
when
)
Deprecated since 7.2. Use format(Instant) instead.

Get age of given java.util.Date compared to now formatted in the same relative format as returned by git log --relative-date

public static String

Returns:

age of given instant compared to now formatted in the same relative format as returned by git log --relative-date
format
(Instant
an instant to format
when
)

Get age of given java.time.Instant 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)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DAY_IN_MILLISback to summary
pack-priv static final long DAY_IN_MILLIS
HOUR_IN_MILLISback to summary
pack-priv static final long HOUR_IN_MILLIS
MINUTE_IN_MILLISback to summary
pack-priv static final long MINUTE_IN_MILLIS
MONTH_IN_MILLISback to summary
pack-priv static final long MONTH_IN_MILLIS
SECOND_IN_MILLISback to summary
pack-priv static final long SECOND_IN_MILLIS
WEEK_IN_MILLISback to summary
pack-priv static final long WEEK_IN_MILLIS
YEAR_IN_MILLISback to summary
pack-priv static final long YEAR_IN_MILLIS

Constructor Detail

RelativeDateFormatterback to summary
public RelativeDateFormatter()

Method Detail

formatback to summary
public static String format(Date when)

Deprecated

since 7.2.

Use format(Instant) instead.

Get age of given java.util.Date compared to now formatted in the same relative format as returned by git log --relative-date

Parameters
when:Date

java.util.Date to format

Returns:String

age of given java.util.Date compared to now formatted in the same relative format as returned by git log --relative-date

Annotations
@Deprecated
since:7.2
@SuppressWarnings:boxing
formatback to summary
public static String format(Instant when)

Get age of given java.time.Instant compared to now formatted in the same relative format as returned by git log --relative-date

Parameters
when:Instant

an instant to format

Returns:String

age of given instant compared to now formatted in the same relative format as returned by git log --relative-date

Annotations
@SuppressWarnings:boxing
Since
7.2
roundback to summary
private static long round(long n, long unit)
upperLimitback to summary
private static long upperLimit(long unit)