InDateRange
See javadoc - uk.gov.gchq.koryphe.impl.predicate.range.InDateRange
Available since Koryphe version 1.1.0
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 InDateRange function = new InDateRange.Builder()
.start("2017/01/01")
.end("2017/02/01")
.build();
{
"class" : "InDateRange",
"start" : "2017/01/01",
"end" : "2017/02/01"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRange",
"start" : "2017/01/01",
"end" : "2017/02/01"
}
g.InDateRange(
start="2017/01/01",
end="2017/02/01"
)
Input type:
java.util.Date
Example inputs:
Input Type | Input | Result |
---|---|---|
java.util.Date | Fri Jan 01 00:00:00 UTC 2016 | false |
java.util.Date | Sun Jan 01 00:00:00 UTC 2017 | true |
java.util.Date | Sun Jan 01 01:00:00 UTC 2017 | true |
java.util.Date | Sun Jan 01 23:59:59 UTC 2017 | true |
java.util.Date | Wed Feb 01 00:00:00 UTC 2017 | true |
java.util.Date | Wed Feb 01 00:00:01 UTC 2017 | false |
null | false |
In date range with second precision
Java
JSON
Full JSON
Python
final InDateRange function = new InDateRange.Builder()
.start("2017/01/01 01:30:10")
.end("2017/01/01 01:30:50")
.build();
{
"class" : "InDateRange",
"start" : "2017/01/01 01:30:10",
"end" : "2017/01/01 01:30:50"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRange",
"start" : "2017/01/01 01:30:10",
"end" : "2017/01/01 01:30:50"
}
g.InDateRange(
start="2017/01/01 01:30:10",
end="2017/01/01 01:30:50"
)
Input type:
java.util.Date
Example inputs:
Input Type | Input | Result |
---|---|---|
java.util.Date | Sun Jan 01 01:30:09 UTC 2017 | false |
java.util.Date | Sun Jan 01 01:30:10 UTC 2017 | true |
java.util.Date | Sun Jan 01 01:30:20 UTC 2017 | true |
java.util.Date | Sun Jan 01 01:30:50 UTC 2017 | true |
java.util.Date | Sun Jan 01 01:30:51 UTC 2017 | false |
null | false |
In date range with timestamps
Java
JSON
Full JSON
Python
final InDateRange function = new InDateRange.Builder()
.start("1483315200")
.end("1485907200")
.build();
{
"class" : "InDateRange",
"start" : "1483315200",
"end" : "1485907200"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRange",
"start" : "1483315200",
"end" : "1485907200"
}
g.InDateRange(
start="1483315200",
end="1485907200"
)
Input type:
java.util.Date
Example inputs:
Input Type | Input | Result |
---|---|---|
java.util.Date | Sun Jan 18 04:01:55 UTC 1970 | false |
java.util.Date | Sun Jan 18 04:01:55 UTC 1970 | true |
java.util.Date | Sun Jan 18 04:01:56 UTC 1970 | true |
java.util.Date | Sun Jan 18 04:45:07 UTC 1970 | true |
java.util.Date | Sun Jan 18 04:45:07 UTC 1970 | false |
null | false |
In date range exclusive
Java
JSON
Full JSON
Python
final InDateRange function = new InDateRange.Builder()
.start("2017/01/01")
.end("2017/02/01")
.startInclusive(false)
.endInclusive(false)
.build();
{
"class" : "InDateRange",
"start" : "2017/01/01",
"end" : "2017/02/01",
"startInclusive" : false,
"endInclusive" : false
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRange",
"start" : "2017/01/01",
"end" : "2017/02/01",
"startInclusive" : false,
"endInclusive" : false
}
g.InDateRange(
start="2017/01/01",
end="2017/02/01",
start_inclusive=False,
end_inclusive=False
)
Input type:
java.util.Date
Example inputs:
Input Type | Input | Result |
---|---|---|
java.util.Date | Fri Jan 01 00:00:00 UTC 2016 | false |
java.util.Date | Sun Jan 01 00:00:00 UTC 2017 | false |
java.util.Date | Sun Jan 01 01:00:00 UTC 2017 | true |
java.util.Date | Sun Jan 01 23:59:59 UTC 2017 | true |
java.util.Date | Wed Feb 01 00:00:00 UTC 2017 | false |
java.util.Date | Wed Feb 01 00:00:01 UTC 2017 | false |
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 InDateRange function = new InDateRange.Builder()
.startOffset(-7L)
// end is not set - it is unbounded
.offsetUnit(TimeUnit.DAY)
.build();
{
"class" : "InDateRange",
"startOffset" : -7,
"offsetUnit" : "DAY"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRange",
"startOffset" : -7,
"offsetUnit" : "DAY"
}
g.InDateRange(
start_offset=-7,
offset_unit="DAY"
)
Input type:
java.util.Date
Example inputs:
Input Type | Input | Result |
---|---|---|
java.util.Date | Mon Oct 03 10:39:24 UTC 2022 | false |
java.util.Date | Wed Oct 05 10:39:24 UTC 2022 | true |
java.util.Date | Mon Oct 10 10:39:24 UTC 2022 | true |
java.util.Date | Tue Oct 11 10:39:24 UTC 2022 | true |
null | false |
Exactly 7 hours ago
Java
JSON
Full JSON
Python
final InDateRange function = new InDateRange.Builder()
.startOffset(-7L)
.endOffset(-6L)
.endInclusive(false)
.offsetUnit(TimeUnit.HOUR)
.build();
{
"class" : "InDateRange",
"startOffset" : -7,
"endOffset" : -6,
"endInclusive" : false,
"offsetUnit" : "HOUR"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InDateRange",
"startOffset" : -7,
"endOffset" : -6,
"endInclusive" : false,
"offsetUnit" : "HOUR"
}
g.InDateRange(
start_offset=-7,
end_offset=-6,
offset_unit="HOUR",
end_inclusive=False
)
Input type:
java.util.Date
Example inputs:
Input Type | Input | Result |
---|---|---|
java.util.Date | Tue Oct 11 02:39:24 UTC 2022 | false |
java.util.Date | Tue Oct 11 03:39:34 UTC 2022 | true |
java.util.Date | Tue Oct 11 04:39:14 UTC 2022 | true |
java.util.Date | Tue Oct 11 04:39:34 UTC 2022 | false |
java.util.Date | Tue Oct 11 10:39:24 UTC 2022 | false |
null | false |