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)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