The problem is the spacing between the date and the time is not fixed in the input, but it is fixed in the pattern. Instead use the padding format character to fix the issue.
I don't like the way the functions seems to be doing an implicit type conversion with formatting. You are not really passing a LocalDateTime but a String. That makes the intention very obscure. I suspect it is not a good practice. I changed my example to use explicit conversions. You could convert the parameter to LocalDateTime explicitly before invoking the function if you prefer it.
fun date_time_format(d: String) =
(d as LocalDateTime {format: "M/d/yy pph:mm:ss a"})
as String {format: "yyyy-MM-dd'T'HH:mm:ss.SSS"}
Output:
{
"concert_time1": "2021-02-01T11:00:00.000",
"concert_time2": "2021-02-01T15:00:00.000"
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…