InTimeRange
See javadoc - uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange
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 time range with day precision
Java
JSON
Full JSON
Python
final InTimeRange function = new InTimeRange.Builder()
.start("2017/01/01")
.end("2017/02/01")
.build();
{
"class" : "InTimeRange",
"start" : "2017/01/01",
"end" : "2017/02/01"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange",
"start" : "2017/01/01",
"end" : "2017/02/01"
}
g.InTimeRange(
start="2017/01/01",
end="2017/02/01"
)
Input type:
java.lang.Long
Example inputs:
Input Type | Input | Result |
---|---|---|
java.lang.Long | 1451606400000 | false |
java.lang.Long | 1483228800000 | true |
java.lang.Long | 1483232400000 | true |
java.lang.Long | 1483315199000 | true |
java.lang.Long | 1485907200000 | true |
java.lang.Long | 1485907201000 | false |
null | false |
In time range with second precision
Java
JSON
Full JSON
Python
final InTimeRange function = new InTimeRange.Builder()
.start("2017/01/01 01:30:10")
.end("2017/01/01 01:30:50")
.build();
{
"class" : "InTimeRange",
"start" : "2017/01/01 01:30:10",
"end" : "2017/01/01 01:30:50"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange",
"start" : "2017/01/01 01:30:10",
"end" : "2017/01/01 01:30:50"
}
g.InTimeRange(
start="2017/01/01 01:30:10",
end="2017/01/01 01:30:50"
)
Input type:
java.lang.Long
Example inputs:
Input Type | Input | Result |
---|---|---|
java.lang.Long | 1483234209000 | false |
java.lang.Long | 1483234210000 | true |
java.lang.Long | 1483234220000 | true |
java.lang.Long | 1483234250000 | true |
java.lang.Long | 1483234251000 | false |
null | false |
In time range with timestamps
Java
JSON
Full JSON
Python
final InTimeRange function = new InTimeRange.Builder()
.start("1483315200")
.end("1485907200")
.build();
{
"class" : "InTimeRange",
"start" : "1483315200",
"end" : "1485907200"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange",
"start" : "1483315200",
"end" : "1485907200"
}
g.InTimeRange(
start="1483315200",
end="1485907200"
)
Input type:
java.lang.Long
Example inputs:
Input Type | Input | Result |
---|---|---|
java.lang.Long | 1483315199 | false |
java.lang.Long | 1483315200 | true |
java.lang.Long | 1483316200 | true |
java.lang.Long | 1485907200 | true |
java.lang.Long | 1485907201 | false |
null | false |
In time range exclusive
Java
JSON
Full JSON
Python
final InTimeRange function = new InTimeRange.Builder()
.start("2017/01/01")
.end("2017/02/01")
.startInclusive(false)
.endInclusive(false)
.build();
{
"class" : "InTimeRange",
"start" : "2017/01/01",
"end" : "2017/02/01",
"startInclusive" : false,
"endInclusive" : false
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange",
"start" : "2017/01/01",
"end" : "2017/02/01",
"startInclusive" : false,
"endInclusive" : false
}
g.InTimeRange(
start="2017/01/01",
end="2017/02/01",
start_inclusive=False,
end_inclusive=False
)
Input type:
java.lang.Long
Example inputs:
Input Type | Input | Result |
---|---|---|
java.lang.Long | 1451606400000 | false |
java.lang.Long | 1483228800000 | false |
java.lang.Long | 1483232400000 | true |
java.lang.Long | 1483315199000 | true |
java.lang.Long | 1485907200000 | false |
java.lang.Long | 1485907201000 | 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 InTimeRange function = new InTimeRange.Builder()
.startOffset(-7L)
// end is not set - it is unbounded
.offsetUnit(TimeUnit.DAY)
.build();
{
"class" : "InTimeRange",
"startOffset" : -7,
"offsetUnit" : "DAY"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange",
"startOffset" : -7,
"offsetUnit" : "DAY"
}
g.InTimeRange(
start_offset=-7,
offset_unit="DAY"
)
Input type:
java.lang.Long
Example inputs:
Input Type | Input | Result |
---|---|---|
java.lang.Long | 1664793565567 | false |
java.lang.Long | 1664966365567 | true |
java.lang.Long | 1665398365567 | true |
java.lang.Long | 1665484765567 | true |
null | false |
Exactly 7 hours ago
Java
JSON
Full JSON
Python
final InTimeRange function = new InTimeRange.Builder()
.startOffset(-7L)
.endOffset(-6L)
.endInclusive(false)
.offsetUnit(TimeUnit.HOUR)
.build();
{
"class" : "InTimeRange",
"startOffset" : -7,
"endOffset" : -6,
"endInclusive" : false,
"offsetUnit" : "HOUR"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange",
"startOffset" : -7,
"endOffset" : -6,
"endInclusive" : false,
"offsetUnit" : "HOUR"
}
g.InTimeRange(
start_offset=-7,
end_offset=-6,
offset_unit="HOUR",
end_inclusive=False
)
Input type:
java.lang.Long
Example inputs:
Input Type | Input | Result |
---|---|---|
java.lang.Long | 1665455965611 | false |
java.lang.Long | 1665459575611 | true |
java.lang.Long | 1665463155611 | true |
java.lang.Long | 1665463175611 | false |
java.lang.Long | 1665484765611 | false |
null | false |
In date range with time unit microseconds
Java
JSON
Full JSON
Python
final InTimeRange function = new InTimeRange.Builder()
.start("2017/01/01 01:30:10")
.end("2017/01/01 01:30:50")
.timeUnit(TimeUnit.MICROSECOND)
.build();
{
"class" : "InTimeRange",
"start" : "2017/01/01 01:30:10",
"end" : "2017/01/01 01:30:50",
"timeUnit" : "MICROSECOND"
}
{
"class" : "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange",
"start" : "2017/01/01 01:30:10",
"end" : "2017/01/01 01:30:50",
"timeUnit" : "MICROSECOND"
}
g.InTimeRange(
start="2017/01/01 01:30:10",
end="2017/01/01 01:30:50",
time_unit="MICROSECOND"
)
Input type:
java.lang.Long
Example inputs:
Input Type | Input | Result |
---|---|---|
java.lang.Long | 1483234209000000 | false |
java.lang.Long | 1483234210000000 | true |
java.lang.Long | 1483234220000000 | true |
java.lang.Long | 1483234250000000 | true |
java.lang.Long | 1483234251000000 | false |
null | false |