Search in sources :

Example 1 with InDateRangeDual

use of uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual in project gaffer-doc by gchq.

the class InDateRangeDualExample method inDateRangeWithDayPrecision.

public void inDateRangeWithDayPrecision() {
    // ---------------------------------------------------------
    final InDateRangeDual function = new InDateRangeDual.Builder().start("2017/01/01").end("2017/02/01").build();
    // ---------------------------------------------------------
    runExample(function, null, new Tuple2<>(getTimestamp("2016/01/01 00:00"), getTimestamp("2016/02/01 00:00")), new Tuple2<>(getTimestamp("2017/01/01 00:00"), getTimestamp("2017/01/01 00:00")), new Tuple2<>(getTimestamp("2017/01/01 01:00"), getTimestamp("2017/01/01 01:00")), new Tuple2<>(getTimestamp("2017/01/01 01:00"), getTimestamp("2017/01/01 23:59:59")), new Tuple2<>(getTimestamp("2017/01/01 01:00"), getTimestamp("2017/02/01 00:00:00")), new Tuple2<>(getTimestamp("2017/01/01 01:00"), getTimestamp("2017/02/01 00:00:01")), new Tuple2<>(null, null));
}
Also used : InDateRangeDual(uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual)

Example 2 with InDateRangeDual

use of uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual in project gaffer-doc by gchq.

the class InDateRangeDualExample method withinTheLastWeek.

public void withinTheLastWeek() {
    // ---------------------------------------------------------
    final InDateRangeDual function = new InDateRangeDual.Builder().startOffset(-7L).offsetUnit(TimeUnit.DAY).build();
    // ---------------------------------------------------------
    runExample(function, "If the end of the range is not specified then the end of the range is unbounded.", new Tuple2<>(new Date(now() - DateUtil.DAYS_TO_MILLISECONDS * 9), new Date(now() - DateUtil.DAYS_TO_MILLISECONDS * 8)), new Tuple2<>(new Date(now() - DateUtil.DAYS_TO_MILLISECONDS * 6), new Date(now() - DateUtil.DAYS_TO_MILLISECONDS * 6 + 1)), new Tuple2<>(new Date(now() - DateUtil.DAYS_TO_MILLISECONDS * 6), new Date(now() - DateUtil.DAYS_TO_MILLISECONDS)), new Tuple2<>(new Date(now() - 10), new Date()), new Tuple2<>(null, null));
}
Also used : InDateRangeDual(uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual) Date(java.util.Date)

Example 3 with InDateRangeDual

use of uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual in project gaffer-doc by gchq.

the class InDateRangeDualExample method inDateRangeWithSecondPrecision.

public void inDateRangeWithSecondPrecision() {
    // ---------------------------------------------------------
    final InDateRangeDual function = new InDateRangeDual.Builder().start("2017/01/01 01:30:10").end("2017/01/01 01:30:50").build();
    // ---------------------------------------------------------
    runExample(function, null, new Tuple2<>(getTimestamp("2017/01/01 01:30:08"), getTimestamp("2017/01/01 01:30:09")), new Tuple2<>(getTimestamp("2017/01/01 01:30:10"), getTimestamp("2017/01/01 01:30:10")), new Tuple2<>(getTimestamp("2017/01/01 01:30:10"), getTimestamp("2017/01/01 01:30:20")), new Tuple2<>(getTimestamp("2017/01/01 01:30:10"), getTimestamp("2017/01/01 01:30:50")), new Tuple2<>(getTimestamp("2017/01/01 01:30:10"), getTimestamp("2017/01/01 01:30:51")), new Tuple2<>(null, null));
}
Also used : InDateRangeDual(uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual)

Example 4 with InDateRangeDual

use of uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual in project gaffer-doc by gchq.

the class InDateRangeDualExample method inDateRangeExclusive.

public void inDateRangeExclusive() {
    // ---------------------------------------------------------
    final InDateRangeDual function = new InDateRangeDual.Builder().start("2017/01/01").end("2017/02/01").startInclusive(false).endInclusive(false).build();
    // ---------------------------------------------------------
    runExample(function, null, new Tuple2<>(getTimestamp("2016/01/01 00:00"), getTimestamp("2016/02/01 00:00")), new Tuple2<>(getTimestamp("2017/01/01 00:00"), getTimestamp("2017/01/01 00:00")), new Tuple2<>(getTimestamp("2017/01/01 01:00"), getTimestamp("2017/01/01 01:00")), new Tuple2<>(getTimestamp("2017/01/01 01:00"), getTimestamp("2017/01/01 23:59:59")), new Tuple2<>(getTimestamp("2017/01/01 01:00"), getTimestamp("2017/02/01 00:00:00")), new Tuple2<>(getTimestamp("2017/01/01 01:00"), getTimestamp("2017/02/01 00:00:01")), new Tuple2<>(null, null));
}
Also used : InDateRangeDual(uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual)

Example 5 with InDateRangeDual

use of uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual in project gaffer-doc by gchq.

the class InDateRangeDualExample method exactly7HoursAgo.

public void exactly7HoursAgo() {
    // ---------------------------------------------------------
    final InDateRangeDual function = new InDateRangeDual.Builder().startOffset(-7L).endOffset(-6L).endInclusive(false).offsetUnit(TimeUnit.HOUR).build();
    // ---------------------------------------------------------
    runExample(function, null, new Tuple2<>(new Date(now() - DateUtil.HOURS_TO_MILLISECONDS * 8), new Date(now() - DateUtil.HOURS_TO_MILLISECONDS * 7 - 10)), new Tuple2<>(new Date(now() - DateUtil.HOURS_TO_MILLISECONDS * 7 + 10000L), new Date(now() - DateUtil.HOURS_TO_MILLISECONDS * 7 + 20000L)), new Tuple2<>(new Date(now() - DateUtil.HOURS_TO_MILLISECONDS * 7 + 10000L), new Date(now() - DateUtil.HOURS_TO_MILLISECONDS * 6 - 10000L)), new Tuple2<>(new Date(now() - DateUtil.HOURS_TO_MILLISECONDS * 7 + 10000L), new Date(now() - DateUtil.HOURS_TO_MILLISECONDS * 6 + 10000L)), new Tuple2<>(new Date(now() - DateUtil.HOURS_TO_MILLISECONDS * 7 + 10000L), new Date(now())), new Tuple2<>(null, null));
}
Also used : InDateRangeDual(uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual) Date(java.util.Date)

Aggregations

InDateRangeDual (uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual)6 Date (java.util.Date)3