It appears that Kotlin is very specific regarding the formats of Date. I am receiving a string in this "Jan 1 2023 12:00AM"
and wanted to convert it into this "yyyy-MM-dd HH:mm:ss.Z"
format. I looked around but couldn’t find a solution.
fun String.FormatDateTime(input: String): String{
val DATE_FORMAT = DateTimeFormatter.ofPattern("MMM dd uuuu")
var dat = aVal.substring(0, input.length-7).trim()
val changeDate = LocalDateTime.parse(dat, DATE_FORMAT)
return ""
}
But its failing. Is there any way to achieve that?