to Date

fun String.toDate(fromFormat: String, locale: Locale = Locale.getDefault()): Date?

Extension method from String to parse to Date

Return

Date if parsing success and null if there's exception

Parameters

fromFormat

format date from String

locale

the locale of the string, default value = Locale.getDefault()


fun Long.toDate(toFormat: String, locale: Locale = Locale.getDefault()): String?

Extension method from Long to format date to String

Return

String if formatting success and null if there's exception

Parameters

toFormat

format String to be formatted

locale

the locale of the result string, default value = Locale.getDefault()

Sources

Link copied to clipboard
Link copied to clipboard