/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
public Object process(Object[] args) { try { return _method.invoke(_instance, _functionInfo.convertTypes(args)); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { //most likely the exception is in the udf, get the exceptio Throwable cause = e.getCause(); if (cause == null) { cause = e; } //some udf's might be configured incorrectly and we dont want to pollute the log //keep track of the last time an exception was logged and reset the counter if the last exception is more than the EXCEPTION_LIMIT_DURATION if (Duration.millis(System.currentTimeMillis() - lastExceptionTime).getStandardMinutes() > EXCEPTION_LIMIT_DURATION) { exceptionCount = 0; } if (exceptionCount < EXCEPTION_LIMIT_RATE) { exceptionCount = exceptionCount + 1; LOGGER.error("Exception invoking method:{} with args:{}, exception message: {}", _method.getName(), Arrays.toString(args), cause.getMessage()); } return null; } } }
/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
public static String humanDuration(final Duration dur) { final Period p = dur.toPeriod().normalizedStandard(); if (dur.getStandardSeconds() == 0) { return "0 seconds"; } else if (dur.getStandardSeconds() < 60) { return format("%d second%s", p.getSeconds(), p.getSeconds() > 1 ? "s" : ""); } else if (dur.getStandardMinutes() < 60) { return format("%d minute%s", p.getMinutes(), p.getMinutes() > 1 ? "s" : ""); } else if (dur.getStandardHours() < 24) { return format("%d hour%s", p.getHours(), p.getHours() > 1 ? "s" : ""); } else { return format("%d day%s", dur.getStandardDays(), dur.getStandardDays() > 1 ? "s" : ""); } }
/** * Return given duration in a human-friendly format. For example, "4 * minutes" or "1 second". Returns only largest meaningful unit of time, * from seconds up to hours. * * The longest duration it supports is hours. * * This method assumes that there are 60 minutes in an hour, * 60 seconds in a minute and 1000 milliseconds in a second. * All currently supplied chronologies use this definition. */ public static CharSequence formatDuration(Context context, ReadableDuration readableDuration) { Resources res = context.getResources(); Duration duration = readableDuration.toDuration(); final int hours = (int) duration.getStandardHours(); if (hours != 0) { return res.getQuantityString(R.plurals.joda_time_android_duration_hours, hours, hours); } final int minutes = (int) duration.getStandardMinutes(); if (minutes != 0) { return res.getQuantityString(R.plurals.joda_time_android_duration_minutes, minutes, minutes); } final int seconds = (int) duration.getStandardSeconds(); return res.getQuantityString(R.plurals.joda_time_android_duration_seconds, seconds, seconds); }
/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
private void clean() { // clean old data DateTime now = DateTime.now(); for (Iterator<Value> it = values.iterator(); it.hasNext();) { Value value = it.next(); if (new Duration(value.getDate(), now).getStandardMinutes() > 1) { it.remove(); } } }
public long durationInMins() { return interval.toDuration().getStandardMinutes(); }
/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
/** * Converts this duration to a period in minutes assuming that there are the * standard number of milliseconds in a minute. * <p> * This method assumes that there are 60 seconds in a minute and * 1000 milliseconds in a second. * All currently supplied chronologies use this definition. * * @return a period representing the number of standard minutes in this period, never null * @throws ArithmeticException if the number of minutes is too large to be represented * @since 2.0 */ public Minutes toStandardMinutes() { long minutes = getStandardMinutes(); return Minutes.minutes(FieldUtils.safeToInt(minutes)); }
public Long getFeedsRefresh() throws ParseException { String d = statementsMap.mapValue(FEEDS, FEEDS_REFRESH); if (d != null) { return durationFormatFactory.create().parse(d).getStandardMinutes(); } else { return null; } }
private Long computeDelay() { Long result = 0L; if (expectedArrivalTime != null && effectiveArrivalTime != null) { LocalTime expected = new LocalTime(expectedArrivalTime); LocalTime effective = new LocalTime(effectiveArrivalTime); Duration duration = new Duration(expected.toDateTimeToday(), effective.toDateTimeToday()); result = duration.getStandardMinutes(); } return result; }
public static int getDateDistanceToReference(VoltageLevel vl) { DateTime caseDate; String caseDateStr = vl.getProperties().getProperty(CASE_DATE); if (caseDateStr == null) { caseDate = vl.getSubstation().getNetwork().getCaseDate(); } else { caseDate = DateTime.parse(caseDateStr); } return (int) new Duration(caseDate, vl.getSubstation().getNetwork().getCaseDate()).getStandardMinutes(); }
public static String humanDuration(final Duration d) { final Period p = d.toPeriod().normalizedStandard(); if (d.getStandardSeconds() == 0) { return "0 seconds"; } else if (d.getStandardSeconds() < 60) { return format("%d second%s", p.getSeconds(), p.getSeconds() > 1 ? "s" : ""); } else if (d.getStandardMinutes() < 60) { return format("%d minute%s", p.getMinutes(), p.getMinutes() > 1 ? "s" : ""); } else if (d.getStandardHours() < 24) { return format("%d hour%s", p.getHours(), p.getHours() > 1 ? "s" : ""); } else { return format("%d day%s", d.getStandardDays(), d.getStandardDays() > 1 ? "s" : ""); } }
@Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof SpecimenType)) { return new NoSpecimen(); } SpecimenType type = (SpecimenType) request; if (!BaseSingleFieldPeriod.class.isAssignableFrom(type.getRawType())) { return new NoSpecimen(); } Duration duration = (Duration) context.resolve(Duration.class); if (type.equals(Seconds.class)) return Seconds.seconds(Math.max(1, (int) duration.getStandardSeconds())); if (type.equals(Minutes.class)) return Minutes.minutes(Math.max(1, (int) duration.getStandardMinutes())); if (type.equals(Hours.class)) return Hours.hours(Math.max(1, (int) duration.getStandardHours())); if (type.equals(Days.class)) return Days.days(Math.max(1, (int) duration.getStandardDays())); if (type.equals(Weeks.class)) return Weeks.weeks(Math.max(1, (int) duration.getStandardDays() / 7)); if (type.equals(Months.class)) return Months.months(Math.max(1, (int) duration.getStandardDays() / 30)); if (type.equals(Years.class)) return Years.years(Math.max(1, (int) duration.getStandardDays() / 365)); return new NoSpecimen(); } }