File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
scala_cli_app/src/main/scala/app Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ package app
2+
3+ import util .DateUtil
4+ import scala .annotation .tailrec
5+ import scala .io .StdIn .readLine
6+ import scala .util .{Success , Try }
7+
8+ object CLIApp extends App {
9+ val date1 = DateUtil .str2Date(getInput)
10+ val date2 = DateUtil .str2Date(getInput)
11+ println(s " date1: ${DateUtil .date2Str(date1)}" )
12+ println(s " date2: ${DateUtil .date2Str(date2)}" )
13+ println(s " yearsBetween: ${DateUtil .yearsBetween(date1, date2)}" )
14+ println(s " compare : ${DateUtil .compare(date1, date2)}" )
15+
16+ @ tailrec
17+ def getInput : String = {
18+ println(" 入力してください (例: 2020-01-01)" )
19+ val input = readLine()
20+
21+ Try (DateUtil .str2Date(input)) match {
22+ case Success (_) => input
23+ case _ => getInput
24+ }
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments