'Which pattern is used to converted MAR, APR, JUN, etc [duplicate]

Im trying to parse date 31-MAR-22 16:49 with this method, but it doesn't works

it throws java.time.format.DateTimeParseException: Text '30-MAR-22 16:49' could not be parsed at index 3

I passed hard coded date "30-Mar-22 16:49" instead of "30-MAR-22 16:49" diff is "Mar" and it worked. I have to know which pattern is used to convert MAR

 getConvertedDates(date: String?): String {
    val format = "MMM d"
    val formatter = DateTimeFormatter.ofPattern("dd-MMM-yy HH:mm")
    val parsedDate = formatter.parse(date)
    val displayFormatter = DateTimeFormatter.ofPattern(format)
    return displayFormatter.format(parsedDate).toString()
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source