InDateRangeDual
See javadoc - uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual
Available since Koryphe version 1.1.0
The predicate tests 2 date inputs (a start date and an end date) are within a defined range. You can configure the start and end time strings using the following formats:
- timestamp in milliseconds
- yyyy/MM
- yyyy/MM/dd
- yyyy/MM/dd HH
- yyyy/MM/dd HH:mm
- yyyy/MM/dd HH:mm:ss
You can use a space, '-', '/', '_', ':', '|', or '.' to separate the parts.
Examples
In date range with day precision
Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
.start("2017/01/01")
.end("2017/02/01")
.build();
{
"class" : "InDateRangeDual",
"start" : "2017/01/01",
"end" : "2017/02/01"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
"start" : "2017/01/01",
"end" : "2017/02/01"
}
g.InDateRangeDual(
start="2017/01/01",
end="2017/02/01"
)
Input type:
java.lang.Comparable, java.lang.Comparable
Example inputs:
Input Type | Input | Result |
---|---|---|
[java.util.Date, java.util.Date] | [Fri Jan 01 00:00:00 UTC 2016, Mon Feb 01 00:00:00 UTC 2016] | false |
[java.util.Date, java.util.Date] | [Sun Jan 01 00:00:00 UTC 2017, Sun Jan 01 00:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:00:00 UTC 2017, Sun Jan 01 01:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:00:00 UTC 2017, Sun Jan 01 23:59:59 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:00:00 UTC 2017, Wed Feb 01 00:00:01 UTC 2017] | true |
[ ,] | [null, null] | false |
In date range with second precision
Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
.start("2017/01/01 01:30:10")
.end("2017/01/01 01:30:50")
.build();
{
"class" : "InDateRangeDual",
"start" : "2017/01/01 01:30:10",
"end" : "2017/01/01 01:30:50"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
"start" : "2017/01/01 01:30:10",
"end" : "2017/01/01 01:30:50"
}
g.InDateRangeDual(
start="2017/01/01 01:30:10",
end="2017/01/01 01:30:50"
)
Input type:
java.lang.Comparable, java.lang.Comparable
Example inputs:
Input Type | Input | Result |
---|---|---|
[java.util.Date, java.util.Date] | [Sun Jan 01 01:30:08 UTC 2017, Sun Jan 01 01:30:09 UTC 2017] | false |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:30:10 UTC 2017, Sun Jan 01 01:30:10 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:30:10 UTC 2017, Sun Jan 01 01:30:20 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:30:10 UTC 2017, Sun Jan 01 01:30:50 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:30:10 UTC 2017, Sun Jan 01 01:30:51 UTC 2017] | true |
[ ,] | [null, null] | false |
In date range with timestamps
Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
.start("1483315200")
.end("1485907200")
.build();
{
"class" : "InDateRangeDual",
"start" : "1483315200",
"end" : "1485907200"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
"start" : "1483315200",
"end" : "1485907200"
}
g.InDateRangeDual(
start="1483315200",
end="1485907200"
)
Input type:
java.lang.Comparable, java.lang.Comparable
Example inputs:
Input Type | Input | Result |
---|---|---|
[java.util.Date, java.util.Date] | [Sun Jan 18 04:01:55 UTC 1970, Sun Jan 18 04:01:55 UTC 1970] | false |
[java.util.Date, java.util.Date] | [Sun Jan 18 04:01:55 UTC 1970, Sun Jan 18 04:01:55 UTC 1970] | true |
[java.util.Date, java.util.Date] | [Sun Jan 18 04:01:55 UTC 1970, Sun Jan 18 04:01:55 UTC 1970] | true |
[java.util.Date, java.util.Date] | [Sun Jan 18 04:01:56 UTC 1970, Sun Jan 18 04:45:07 UTC 1970] | true |
[java.util.Date, java.util.Date] | [Sun Jan 18 04:01:56 UTC 1970, Sun Jan 18 04:45:07 UTC 1970] | true |
[ ,] | [null, null] | false |
In date range exclusive
Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
.start("2017/01/01")
.end("2017/02/01")
.startInclusive(false)
.endInclusive(false)
.build();
{
"class" : "InDateRangeDual",
"start" : "2017/01/01",
"end" : "2017/02/01",
"startInclusive" : false,
"endInclusive" : false
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
"start" : "2017/01/01",
"end" : "2017/02/01",
"startInclusive" : false,
"endInclusive" : false
}
g.InDateRangeDual(
start="2017/01/01",
end="2017/02/01",
start_inclusive=False,
end_inclusive=False
)
Input type:
java.lang.Comparable, java.lang.Comparable
Example inputs:
Input Type | Input | Result |
---|---|---|
[java.util.Date, java.util.Date] | [Fri Jan 01 00:00:00 UTC 2016, Mon Feb 01 00:00:00 UTC 2016] | false |
[java.util.Date, java.util.Date] | [Sun Jan 01 00:00:00 UTC 2017, Sun Jan 01 00:00:00 UTC 2017] | false |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:00:00 UTC 2017, Sun Jan 01 01:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:00:00 UTC 2017, Sun Jan 01 23:59:59 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sun Jan 01 01:00:00 UTC 2017, Wed Feb 01 00:00:01 UTC 2017] | true |
[ ,] | [null, null] | false |
Within the last week
If the end of the range is not specified then the end of the range is unbounded.
Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
.startOffset(-7L)
// end is not set - it is unbounded
.offsetUnit(TimeUnit.DAY)
.build();
{
"class" : "InDateRangeDual",
"startOffset" : -7,
"offsetUnit" : "DAY"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
"startOffset" : -7,
"offsetUnit" : "DAY"
}
g.InDateRangeDual(
start_offset=-7,
offset_unit="DAY"
)
Input type:
java.lang.Comparable, java.lang.Comparable
Example inputs:
Input Type | Input | Result |
---|---|---|
[java.util.Date, java.util.Date] | [Sun Oct 02 10:39:23 UTC 2022, Mon Oct 03 10:39:23 UTC 2022] | false |
[java.util.Date, java.util.Date] | [Wed Oct 05 10:39:23 UTC 2022, Wed Oct 05 10:39:23 UTC 2022] | true |
[java.util.Date, java.util.Date] | [Wed Oct 05 10:39:23 UTC 2022, Mon Oct 10 10:39:23 UTC 2022] | true |
[java.util.Date, java.util.Date] | [Tue Oct 11 10:39:23 UTC 2022, Tue Oct 11 10:39:23 UTC 2022] | true |
[ ,] | [null, null] | false |
Exactly 7 hours ago
Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
.startOffset(-7L)
.endOffset(-6L)
.endInclusive(false)
.offsetUnit(TimeUnit.HOUR)
.build();
{
"class" : "InDateRangeDual",
"startOffset" : -7,
"endOffset" : -6,
"endInclusive" : false,
"offsetUnit" : "HOUR"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
"startOffset" : -7,
"endOffset" : -6,
"endInclusive" : false,
"offsetUnit" : "HOUR"
}
g.InDateRangeDual(
start_offset=-7,
end_offset=-6,
offset_unit="HOUR",
end_inclusive=False
)
Input type:
java.lang.Comparable, java.lang.Comparable
Example inputs:
Input Type | Input | Result |
---|---|---|
[java.util.Date, java.util.Date] | [Tue Oct 11 02:39:23 UTC 2022, Tue Oct 11 03:39:23 UTC 2022] | false |
[java.util.Date, java.util.Date] | [Tue Oct 11 03:39:33 UTC 2022, Tue Oct 11 03:39:43 UTC 2022] | true |
[java.util.Date, java.util.Date] | [Tue Oct 11 03:39:33 UTC 2022, Tue Oct 11 04:39:13 UTC 2022] | true |
[java.util.Date, java.util.Date] | [Tue Oct 11 03:39:33 UTC 2022, Tue Oct 11 04:39:33 UTC 2022] | true |
[java.util.Date, java.util.Date] | [Tue Oct 11 03:39:33 UTC 2022, Tue Oct 11 10:39:23 UTC 2022] | true |
[ ,] | [null, null] | false |
Fully uncontained range
Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
.start("2017/03/01")
.end("2017/08/01")
.startFullyContained(false)
.endFullyContained(false)
.build();
{
"class" : "InDateRangeDual",
"start" : "2017/03/01",
"end" : "2017/08/01",
"endFullyContained" : false,
"startFullyContained" : false
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
"start" : "2017/03/01",
"end" : "2017/08/01",
"endFullyContained" : false,
"startFullyContained" : false
}
g.InDateRangeDual(
start="2017/03/01",
end="2017/08/01",
start_fully_contained=False,
end_fully_contained=False
)
Input type:
java.lang.Comparable, java.lang.Comparable
Example inputs:
Input Type | Input | Result |
---|---|---|
[java.util.Date, java.util.Date] | [Sun Jan 01 00:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017] | false |
[java.util.Date, java.util.Date] | [Sun Jan 01 00:00:00 UTC 2017, Sat Apr 01 00:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sat Apr 01 00:00:00 UTC 2017, Mon May 01 00:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sat Apr 01 00:00:00 UTC 2017, Fri Sep 01 00:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Fri Sep 01 00:00:00 UTC 2017, Sun Oct 01 00:00:00 UTC 2017] | false |
[ ,] | [null, null] | false |
Start contained range
Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
.start("2017/03/01")
.end("2017/08/01")
.startFullyContained(true)
.endFullyContained(false)
.build();
{
"class" : "InDateRangeDual",
"start" : "2017/03/01",
"end" : "2017/08/01",
"endFullyContained" : false,
"startFullyContained" : true
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
"start" : "2017/03/01",
"end" : "2017/08/01",
"endFullyContained" : false,
"startFullyContained" : true
}
g.InDateRangeDual(
start="2017/03/01",
end="2017/08/01",
start_fully_contained=True,
end_fully_contained=False
)
Input type:
java.lang.Comparable, java.lang.Comparable
Example inputs:
Input Type | Input | Result |
---|---|---|
[java.util.Date, java.util.Date] | [Sun Jan 01 00:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017] | false |
[java.util.Date, java.util.Date] | [Sun Jan 01 00:00:00 UTC 2017, Sat Apr 01 00:00:00 UTC 2017] | false |
[java.util.Date, java.util.Date] | [Sat Apr 01 00:00:00 UTC 2017, Mon May 01 00:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sat Apr 01 00:00:00 UTC 2017, Fri Sep 01 00:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Fri Sep 01 00:00:00 UTC 2017, Sun Oct 01 00:00:00 UTC 2017] | false |
[ ,] | [null, null] | false |
Fully contained range
Java
JSON
Full JSON
Python
final InDateRangeDual function = new InDateRangeDual.Builder()
.start("2017/03/01")
.end("2017/08/01")
.startFullyContained(true)
.endFullyContained(true)
.build();
{
"class" : "InDateRangeDual",
"start" : "2017/03/01",
"end" : "2017/08/01",
"endFullyContained" : true,
"startFullyContained" : true
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual",
"start" : "2017/03/01",
"end" : "2017/08/01",
"endFullyContained" : true,
"startFullyContained" : true
}
g.InDateRangeDual(
start="2017/03/01",
end="2017/08/01",
start_fully_contained=True,
end_fully_contained=True
)
Input type:
java.lang.Comparable, java.lang.Comparable
Example inputs:
Input Type | Input | Result |
---|---|---|
[java.util.Date, java.util.Date] | [Sun Jan 01 00:00:00 UTC 2017, Wed Feb 01 00:00:00 UTC 2017] | false |
[java.util.Date, java.util.Date] | [Sun Jan 01 00:00:00 UTC 2017, Sat Apr 01 00:00:00 UTC 2017] | false |
[java.util.Date, java.util.Date] | [Sat Apr 01 00:00:00 UTC 2017, Mon May 01 00:00:00 UTC 2017] | true |
[java.util.Date, java.util.Date] | [Sat Apr 01 00:00:00 UTC 2017, Fri Sep 01 00:00:00 UTC 2017] | false |
[java.util.Date, java.util.Date] | [Fri Sep 01 00:00:00 UTC 2017, Sun Oct 01 00:00:00 UTC 2017] | false |
[ ,] | [null, null] | false |