format

@JvmStatic
@JvmOverloads
fun format(date: Long, locale: String = default, clock: Long = nowInMilliseconds(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String

Formats provided date to a fuzzy time like 'a moment ago'.

  • If locale is passed will look for message for that locale, if you want to add or override locales use setLocaleMessages. Defaults to 'en'.

  • If clock is passed this will be the point of reference for calculating the elapsed time. Defaults to nowInMilliseconds

  • If minCutOff is passed from that date bellow all prefix and suffix disabled to show date without ago. Default value is None.

  • If isWeekFormatEnabled is true, week format enabled and show 7 days - 28 days as 1 week to 4 week.

  • If allowFromNow is true, format will use the Form prefix, i.e. a date 5 minutes from now in 'en' locale will display as "5 minutes from now".

Note: This function uses ISO 639-1 language code to identify the language. For more information see ISO 639-1.

Example:

TimeAgo.format(nowInMilliseconds()) // "a moment ago"

Since

1.1.0


@JvmStatic
@JvmOverloads
fun format(date: Date, locale: String = default, clock: Date = nowInDate(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String

Formats provided date to a fuzzy time like 'a moment ago'.

  • If locale is passed will look for message for that locale, if you want to add or override locales use setLocaleMessages. Defaults to 'en'.

  • If clock is passed this will be the point of reference for calculating the elapsed time. Defaults to nowInDate

  • If minCutOff is passed from that date bellow all prefix and suffix disabled to show date without ago. Default value is None.

  • If isWeekFormatEnabled is true, week format enabled and show 7 days - 28 days as 1 week to 4 week.

  • If allowFromNow is true, format will use the Form prefix, i.e. a date 5 minutes from now in 'en' locale will display as "5 minutes from now".

Note: This function uses ISO 639-1 language code to identify the language. For more information see ISO 639-1.

Example:

TimeAgo.format(nowInDate()) // "a moment ago"

Since

1.1.0


@JvmStatic
@JvmOverloads
fun format(date: Calendar, locale: String = default, clock: Calendar = nowInCalendar(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String

Formats provided date to a fuzzy time like 'a moment ago'.

  • If locale is passed will look for message for that locale, if you want to add or override locales use setLocaleMessages. Defaults to 'en'.

  • If clock is passed this will be the point of reference for calculating the elapsed time. Defaults to nowInCalendar

  • If minCutOff is passed from that date bellow all prefix and suffix disabled to show date without ago. Default value is None.

  • If isWeekFormatEnabled is true, week format enabled and show 7 days - 28 days as 1 week to 4 week.

  • If allowFromNow is true, format will use the Form prefix, i.e. a date 5 minutes from now in 'en' locale will display as "5 minutes from now".

Note: This function uses ISO 639-1 language code to identify the language. For more information see ISO 639-1.

Example:

TimeAgo.format(nowInCalendar()) // "a moment ago"

Since

1.1.0


@JvmStatic
@JvmOverloads
fun format(date: Instant, locale: String = default, clock: Instant = now(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String

Formats provided date to a fuzzy time like 'a moment ago'.

  • If locale is passed will look for message for that locale, if you want to add or override locales use setLocaleMessages. Defaults to 'en'.

  • If clock is passed this will be the point of reference for calculating the elapsed time. Defaults to now

  • If minCutOff is passed from that date bellow all prefix and suffix disabled to show date without ago. Default value is None.

  • If isWeekFormatEnabled is true, week format enabled and show 7 days - 28 days as 1 week to 4 week.

  • If allowFromNow is true, format will use the Form prefix, i.e. a date 5 minutes from now in 'en' locale will display as "5 minutes from now".

Note: This function uses ISO 639-1 language code to identify the language. For more information see ISO 639-1.

Example:

TimeAgo.format(now()) // "a moment ago"

Since

1.1.0


@JvmStatic
@JvmOverloads
fun format(date: LocalDateTime, locale: String = default, clock: LocalDateTime = nowInLocalDateTime(), minCutOff: DateLimitation = None, isWeekFormatEnabled: Boolean = false, allowFromNow: Boolean = false): String

Formats provided date to a fuzzy time like 'a moment ago'.

  • If locale is passed will look for message for that locale, if you want to add or override locales use setLocaleMessages. Defaults to 'en'.

  • If clock is passed this will be the point of reference for calculating the elapsed time. Defaults to nowInLocalDateTime

  • If minCutOff is passed from that date bellow all prefix and suffix disabled to show date without ago. Default value is None.

  • If isWeekFormatEnabled is true, week format enabled and show 7 days - 28 days as 1 week to 4 week.

  • If allowFromNow is true, format will use the Form prefix, i.e. a date 5 minutes from now in 'en' locale will display as "5 minutes from now".

Note: This function uses ISO 639-1 language code to identify the language. For more information see ISO 639-1.

Example:

TimeAgo.format(nowInLocalDateTime()) // "a moment ago"

Since

1.1.0