Skip to content

Latest commit

 

History

History
43 lines (37 loc) · 1.35 KB

File metadata and controls

43 lines (37 loc) · 1.35 KB

Core Date

DateFormatExtensions

A set of extension functions to convert ZonedDateTime to String in both way. Also contains CommonFormats singleton object which contains the most commonly used date formats

Sample usage:

 val stringDate = ZonedDateTime.now().toStringWithFormat(CommonFormats.FORMAT_SIMPLE_DATE)

And in the opposite direction

val date = stringDate.toDate(CommonFormats.FORMAT_SIMPLE_DATE)

Note: DateTimeFormatter objects will be created once and cached by params of methods [dateFormat] and [locale].

There is also an alternative version:

val dateFormat = DateTimeFormatter.ofPattern(CommonFormats.FORMAT_SIMPLE_DATE, Locale.getDefault())
val stringDate = ZonedDateTime.now().toStringWithFormat(dateFormat)

And in the opposite direction

val dateFormat = DateTimeFormatter.ofPattern(CommonFormats.FORMAT_SIMPLE_DATE, Locale.getDefault())
val date = stringDate.toDate(dateFormat)

DateHelperExtensions

A set of extension functions to work with Date Such as

val date = ZonedDateTime.now()
val result: Boolean = date.isToday()
val result: Boolean = date.isYesterday()

For full list of methods, please look to the source code, example project or view documentation