
caseapp.core.PlatformArgParsers.scala Maven / Gradle / Ivy
package caseapp.core
import java.text.{ SimpleDateFormat, ParseException }
import java.util.{ Calendar, GregorianCalendar }
trait PlatformArgParsers {
implicit def calendar: ArgParser[Calendar] =
ArgParser.instance {
val fmt = new SimpleDateFormat("yyyy-MM-dd")
s =>
try {
val c = new GregorianCalendar
c setTime fmt.parse(s)
Right(c)
} catch { case e: ParseException =>
Left(s"Cannot parse date: $s")
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy