0

Ican't understand why I am getting error on Following code on September Month

    var dateFormat: SimpleDateFormat = SimpleDateFormat("dd-MMM-yyyy")
    val    vdate:String="09-Sep-2022"
    val ndate :Date = dateFormat.parse(vdate)
    sampeltextview.text=ndate.toString()

errori am getting is : Unparseable date: "09-Sep-2022"

But when I change Month other than September for ex. Jun , Jul ect.

user3857903
  • 52
  • 11
  • 2
    have you tried "Sept" instead of Sep? – Stultuske Mar 14 '22 at 10:51
  • yeah its working with Sept any specific reason there? – user3857903 Mar 14 '22 at 10:58
  • It is depending on `AbbreviatedMonthGenitiveNames` which is different in different language – drjansari Mar 14 '22 at 12:57
  • Not answering your question, I recommend you don’t use `SimpleDateFormat` and `Date`. Those classes are poorly designed and long outdated, the former in particular notoriously troublesome. Instead use `LocalDate` and `DateTimeFormatter`, both from [java.time, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/). – Ole V.V. Mar 15 '22 at 09:11

0 Answers0