I am using DateTimeFormatter in scala and now it is giving me trouble with a serialization.
The error is occurring because the function is still being defined outside the scope of your map. Re-format how your map is operating to include the DateTimeFormatter being defined inside of map as follows:
val evega = concat.map(_.split(",")).keyBy(_(0)).groupByKey().map{case (k, v) => {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val parsedDates = v.map(sa => LocalDate.parse(sa(1), formatter))
parsedDates.max.getDayOfYear - parsedDates.min.getDayOfYear
}}