How to deal with such a mistake? When choosing the 31st of a month ago or forward. I put on the date of the dialogue October 31, and the error is in September. A month ago.

Cannot parse "2018 9 31 14 38": Value 31 for dayOfMonth must be in the range [1,30]

 val dateTime = DateTime.parse("$mYear-$mMonth-$mDay $hourOfDay:$minute", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm")) dateTime.toString("yyyy-MM-dd'T'HH:mm:ssZ") 
  • one
    June 30 days. - user218976
  • @Anamnian updated the entry. I put on the date of the dialogue October 31, and the error is in September. - nuqss
  • one
    In September, also 30 days. - user218976

1 answer 1

 val dateTime = DateTime.parse("$mYear-${mMonth+1}-$mDay $hourOfDay:$minute", DateTimeFormat.forPattern("yyyy-MM-dd HH:mm")) dateTime.toString("yyyy-MM-dd'T'HH:mm:ssZ")