val posted = LocalDateTime.now()val postedEnd = posted.plusDays(10)// 4 - 14 Octoberval text = DateUtils.formatDateRange(context, posted.toMillis()!!, postedEnd.toMillis()!!, DateUtils.FORMAT_ABBREV_MONTH)
NOTE: Refer LocalDateTime.toMillis
fun formatDate(context: Context, posted: LocalDateTime, postedEnd: LocalDateTime? = null, flags: Int = DateUtils.FORMAT_ABBREV_MONTH): String? { return if (postedEnd == null) DateUtils.formatDateTime(context, posted.toMillis()!!, flags) else DateUtils.formatDateRange(context, posted.toMillis()!!, postedEnd.toMillis()!!, flags)}
References: