count = Minutes.minutesIn(interval).getMinutes(); if (past) { if (abbrevRelative) {
private static String getMinutesCron(Period p) { Integer min = p.getMinutes(); Minutes m = p.toStandardMinutes(); Integer minutes = m.getMinutes(); String str = "0" + (min > 0 ? "/" + min : ""); if (minutes > 60) { str = min + ""; } return str; }
assertFunction("date_diff('minute', " + baseDateTimeLiteral + ", " + TIMESTAMP_LITERAL + ")", BIGINT, (long) minutesBetween(baseDateTime, TIMESTAMP).getMinutes()); assertFunction("date_diff('hour', " + baseDateTimeLiteral + ", " + TIMESTAMP_LITERAL + ")", BIGINT, (long) hoursBetween(baseDateTime, TIMESTAMP).getHours()); assertFunction("date_diff('day', " + baseDateTimeLiteral + ", " + TIMESTAMP_LITERAL + ")", BIGINT, (long) daysBetween(baseDateTime, TIMESTAMP).getDays()); assertFunction("date_diff('minute', " + weirdBaseDateTimeLiteral + ", " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) minutesBetween(weirdBaseDateTime, WEIRD_TIMESTAMP).getMinutes()); assertFunction("date_diff('hour', " + weirdBaseDateTimeLiteral + ", " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT,
@Override public Integer toNonNullValue(Minutes value) { return value.getMinutes(); } }
@Override public long getDiff(Interval interval) { return Minutes.minutesIn(interval).getMinutes(); } },
/** @return Minutes between {@link #getStart()} and {@link #getEnd()} */ public int getTotalDuration() { int d = this.duration; if (d < 0) { d = Minutes.minutesBetween(this.start, this.end).getMinutes(); d = Math.abs(d); this.duration = d; } return d; }
@Override public int numIn(ReadableInterval interval) { return Minutes.minutesIn(interval).getMinutes() / 10; }
@Override public int numIn(ReadableInterval interval) { return Minutes.minutesIn(interval).getMinutes(); }
@Override public int numIn(ReadableInterval interval) { return Minutes.minutesIn(interval).getMinutes() / 15; }
@Override public int numIn(ReadableInterval interval) { return Minutes.minutesIn(interval).getMinutes() / 5; }
@Override public int numIn(ReadableInterval interval) { return Minutes.minutesIn(interval).getMinutes(); } },
// Get difference, same as before Minutes difference = ((Minutes.minutesBetween(airTime1,startTime1))); // Create string representation of difference // (Minutes.toString() representation exists but is hard to read) String diffStr = difference.getMinutes() / 60.0 + " hours" // for, e.g., "3.5 hours" // Re-use your old graphics code with new string Graphics g = image2.getGraphics(); g.setFont(g.getFont().deriveFont(30f)); g.drawString(diffStr, 100, 100); g.dispose();
@Override public int numIn(ReadableInterval interval) { return Minutes.minutesIn(interval).getMinutes() / 15; }
@Override public int numIn(ReadableInterval interval) { return Minutes.minutesIn(interval).getMinutes(); }
@Override public int numIn(ReadableInterval interval) { return Minutes.minutesIn(interval).getMinutes() / 5; }
/** * Converts seconds to mins. * * @param seconds to be converted. * @return mins equivalent of seconds */ public static int SECONDS_TO_MINUTES(int seconds) { Period period = new Period(Seconds.seconds(seconds)); return period.toStandardMinutes().getMinutes(); }
private static String getMinutesCron(Period p) { Integer min = p.getMinutes(); Minutes m = p.toStandardMinutes(); Integer minutes = m.getMinutes(); String str = "0" + (min > 0 ? "/" + min : ""); if (minutes > 60) { str = min + ""; } return str; }
/** * @return Minutes between {@link #getStart()} and the end parameter, if the parameter is after * {@link #getEnd()} then {@link #getEnd()} is used */ public int getDurationTo(ReadableInstant end) { if (end.isAfter(this.end)) { return this.getTotalDuration(); } return Math.abs(Minutes.minutesBetween(this.start, end).getMinutes()); }
public double hoursAfter(int hour) { HourMinuteSecond afterHour = new HourMinuteSecond(hour, 0, 0); if (!getBeginHourMinuteSecond().isBefore(afterHour)) { return getUnitHours().doubleValue(); } else if (getEndHourMinuteSecond().isAfter(afterHour)) { return BigDecimal.valueOf(Minutes.minutesBetween(afterHour, getEndHourMinuteSecond()).getMinutes()) .divide(BigDecimal.valueOf(NUMBER_OF_MINUTES_IN_HOUR), 2, RoundingMode.HALF_UP).doubleValue(); } return 0.0; }
@ProcessElement public void processElement(ProcessContext c, BoundedWindow window) { IntervalWindow w = (IntervalWindow) window; int duration = new Duration(w.start(), w.end()).toPeriod().toStandardMinutes().getMinutes(); c.output(duration); } }