So my Kotlin
app is accepting an input String that should be a date in a certain format:
fun haveFun(dateStr: String){
var formatter = DateTimeFormatter.ofPattern("dd-MMM-yyyy")
var formattedDate = dateStr.format(formatter)
println(formattedDate)
}
The issue is that no matter which input string I send, it seems that everything is valid and no error is thrown.
The program is cool with whatever text I sent it: 61-Boby-2019
or even I'm not a date
From Java I'm used to some exception to be thrown or an isValid
method, but I didn't find such yet in Kotlin