Created
December 27, 2020 22:22
-
-
Save Haaroon/5171ac7d40f7969d5d19c5ecc0eee599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit class DateInterpolator(val sc: StringContext) extends AnyVal { | |
def date(args: Any*): LocalDate = { | |
if (args.length != 3) throw new IllegalArgumentException("Need 3 inputs") | |
else { | |
try { | |
var year = args(0).toString.toInt | |
var month = args(1).toString.toInt | |
var day = args(2).toString.toInt | |
LocalDate.of(year, month, day) | |
} catch { | |
case _: NumberFormatException => throw new IllegalArgumentException("Number not given") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment