DateTimeFormatter


class DateTimeFormatter


DateTimeFormatter is a class for international-aware date/time formatting.

It is designed to encourage best i18n practices, and work correctly on old / new Android versions, without having to test the API level everywhere.

Summary

Public constructors

DateTimeFormatter(
    options: DateTimeFormatterJdkStyleOptions,
    locale: Locale
)
DateTimeFormatter(
    context: Context,
    options: DateTimeFormatterSkeletonOptions,
    locale: Locale
)

Public functions

String
format(calendar: Calendar)

Formats a Calendar object into a user friendly locale aware date/time string.

String
format(date: Date)

Formats a Date object into a user friendly locale aware date/time string.

String
format(milliseconds: Long)

Formats an epoch time into a user friendly, locale aware, date/time string.

Public constructors

DateTimeFormatter

Added in 1.0.0-alpha01
DateTimeFormatter(
    options: DateTimeFormatterJdkStyleOptions,
    locale: Locale = getDefaultFormattingLocale()
)

DateTimeFormatter

Added in 1.0.0-alpha01
DateTimeFormatter(
    context: Context,
    options: DateTimeFormatterSkeletonOptions,
    locale: Locale = getDefaultFormattingLocale()
)

Public functions

format

Added in 1.0.0-alpha01
fun format(calendar: Calendar): String

Formats a Calendar object into a user friendly locale aware date/time string.

Parameters
calendar: Calendar

the date / time to format.

Returns
String

the formatted date / time string.

format

Added in 1.0.0-alpha01
fun format(date: Date): String

Formats a Date object into a user friendly locale aware date/time string.

Parameters
date: Date

the date / time to format.

Returns
String

the formatted date / time string.

format

Added in 1.0.0-alpha01
fun format(milliseconds: Long): String

Formats an epoch time into a user friendly, locale aware, date/time string.

Parameters
milliseconds: Long

the date / time to format expressed in milliseconds since January 1, 1970, 00:00:00 GMT.

Returns
String

the formatted date / time string.