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( |
DateTimeFormatter( |
Public functions |
|
|---|---|
String |
Formats a Calendar object into a user friendly locale aware date/time string. |
String |
Formats a Date object into a user friendly locale aware date/time string. |
String |
Formats an epoch time into a user friendly, locale aware, date/time string. |
Public constructors
DateTimeFormatter
DateTimeFormatter(
options: DateTimeFormatterJdkStyleOptions,
locale: Locale = getDefaultFormattingLocale()
)
DateTimeFormatter
DateTimeFormatter(
context: Context,
options: DateTimeFormatterSkeletonOptions,
locale: Locale = getDefaultFormattingLocale()
)
Public functions
format
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
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
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. |