Please see this function that convert String
into LocalDate
:
def getLocalDate(date: String): LocalDate = {
LocalDate.parse(date, format.DateTimeFormatter.ofPattern("dd MMM, yyyy"))
}
Usage:
val date = "01 Jan, 2010"
val localDate = getLocalDate(date)
So in case i have date with different format:
val date = "01 Jan, 2010"
Is it possible to enable my function to support several formats instead of support only 1 ?