@@ -1,5 +1,5 @@ |
/* |
- * $Id: 2.7+14 Check.java 773d4dd2e419 2022-10-27 od $ |
+ * $Id$ |
* |
* This file is part of the Cloud Services Integration Platform (CSIP), |
* a Model-as-a-Service framework, API and application suite. |
@@ -233,9 +233,12 @@ |
return this; |
} |
|
+ // start and end are inclusive |
public Check inBetween(LocalDate start, LocalDate end) { |
checks.add(n -> { |
- LocalDate d = (LocalDate) n; |
+ LocalDate d = toLocalDate(n); |
+ if (d.equals(start) || d.equals(end)) |
+ return null; |
if (!(d.isAfter(start) && d.isBefore(end))) |
return d + " not in date range " + start + "..." + end; |
return null; |
@@ -288,7 +291,7 @@ |
return this; |
} |
|
- private double toDouble(Object o) { |
+ private static double toDouble(Object o) { |
if (o instanceof Number) |
return ((Number) o).doubleValue(); |
if (o instanceof String) { |
@@ -297,7 +300,18 @@ |
throw new IllegalArgumentException(o + " cannot be converted into double."); |
} |
|
- private int toInt(Object o) { |
+ public static LocalDate toLocalDate(Object o) { |
+ if (o instanceof LocalDate) |
+ return (LocalDate) o; |
+ if (o instanceof String) { |
+ String date = o.toString(); |
+ LocalDate ld = LocalDate.parse(date, DateTimeFormatter.ISO_DATE); |
+ return ld; |
+ } |
+ throw new IllegalArgumentException(o + " cannot be converted into double."); |
+ } |
+ |
+ private static int toInt(Object o) { |
if (o instanceof Number) |
return ((Number) o).intValue(); |
if (o instanceof String) { |