Skip to content

Instantly share code, notes, and snippets.

@stephen-lazaro
Created October 4, 2018 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephen-lazaro/f1218f04e51547f08a84b8168f884113 to your computer and use it in GitHub Desktop.
Save stephen-lazaro/f1218f04e51547f08a84b8168f884113 to your computer and use it in GitHub Desktop.
// One way to parse a date:
val slashParser = DateTimeFormatter.ofPattern("yyyy/MM/dd")
// Another way to parse a date:
val dashParser = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val withSlashes: RowDecoder[Date] =
  RowDecoder.from(x => Either.catchNonFatal(slashParser.parse(x)))
val withDashes: RowDecoder[Date] =
  RowDecoder.from(x => Either.catchNonFatal(dashParser.parse(x)))
// What do we do here ???
val eitherWithSlashesOrDashes: RowDecoder[Date] = ???
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment