DateTimeFormatter


public final 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(
    @NonNull Context context,
    @NonNull DateTimeFormatterSkeletonOptions options,
    @NonNull Locale locale
)

Public methods

final @NonNull String
format(@NonNull Calendar calendar)

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

final @NonNull String

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

final @NonNull String
format(long milliseconds)

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

Public constructors

DateTimeFormatter

Added in 1.0.0-alpha01
public DateTimeFormatter(
    @NonNull DateTimeFormatterJdkStyleOptions options,
    @NonNull Locale locale
)

DateTimeFormatter

Added in 1.0.0-alpha01
public DateTimeFormatter(
    @NonNull Context context,
    @NonNull DateTimeFormatterSkeletonOptions options,
    @NonNull Locale locale
)

Public methods

format

Added in 1.0.0-alpha01
public final @NonNull String format(@NonNull Calendar calendar)

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

Parameters
@NonNull Calendar calendar

the date / time to format.

Returns
@NonNull String

the formatted date / time string.

format

Added in 1.0.0-alpha01
public final @NonNull String format(@NonNull Date date)

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

Parameters
@NonNull Date date

the date / time to format.

Returns
@NonNull String

the formatted date / time string.

format

Added in 1.0.0-alpha01
public final @NonNull String format(long milliseconds)

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

Parameters
long milliseconds

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

Returns
@NonNull String

the formatted date / time string.