/** * Resolves singletons. * * @return the singleton instance */ private Object readResolve() { return Minutes.minutes(getValue()); }
/** * Resolves singletons. * * @return the singleton instance */ private Object readResolve() { return Minutes.minutes(getValue()); }
/** * Converts this period in seconds to a period in minutes assuming a * 60 second minute. * <p> * This method allows you to convert between different types of period. * However to achieve this it makes the assumption that all minutes are * 60 seconds long. * This may not be true for some unusual chronologies. However, it is included * as it is a useful operation for many applications and business rules. * * @return a period representing the number of minutes for this number of seconds */ public Minutes toStandardMinutes() { return Minutes.minutes(getValue() / DateTimeConstants.SECONDS_PER_MINUTE); }
private ReadablePeriod parseDuration(final String duration) { final int hour = Integer.parseInt(duration.split(":")[0]); final int min = Integer.parseInt(duration.split(":")[1]); return Minutes.minutes(min + hour * 60).toPeriod(); }
/** * Returns a new instance with the minutes divided by the specified divisor. * The calculation uses integer division, thus 3 divided by 2 is 1. * <p> * This instance is immutable and unaffected by this method call. * * @param divisor the amount to divide by, may be negative * @return the new period divided by the specified divisor * @throws ArithmeticException if the divisor is zero */ public Minutes dividedBy(int divisor) { if (divisor == 1) { return this; } return Minutes.minutes(getValue() / divisor); }
/** * Converts this period in seconds to a period in minutes assuming a * 60 second minute. * <p> * This method allows you to convert between different types of period. * However to achieve this it makes the assumption that all minutes are * 60 seconds long. * This may not be true for some unusual chronologies. However, it is included * as it is a useful operation for many applications and business rules. * * @return a period representing the number of minutes for this number of seconds */ public Minutes toStandardMinutes() { return Minutes.minutes(getValue() / DateTimeConstants.SECONDS_PER_MINUTE); }
/** * Returns a new instance with the minutes value negated. * * @return the new period with a negated value * @throws ArithmeticException if the result overflows an int */ public Minutes negated() { return Minutes.minutes(FieldUtils.safeNegate(getValue())); }
/** * Returns a new instance with the minutes multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Minutes multipliedBy(int scalar) { return Minutes.minutes(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Creates a <code>Minutes</code> representing the number of whole minutes * between the two specified datetimes. * * @param start the start instant, must not be null * @param end the end instant, must not be null * @return the period in minutes * @throws IllegalArgumentException if the instants are null or invalid */ public static Minutes minutesBetween(ReadableInstant start, ReadableInstant end) { int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.minutes()); return Minutes.minutes(amount); }
/** * Returns a new instance with the minutes multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Minutes multipliedBy(int scalar) { return Minutes.minutes(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the minutes value negated. * * @return the new period with a negated value * @throws ArithmeticException if the result overflows an int */ public Minutes negated() { return Minutes.minutes(FieldUtils.safeNegate(getValue())); }
/** * Creates a <code>Minutes</code> representing the number of whole minutes * between the two specified datetimes. * * @param start the start instant, must not be null * @param end the end instant, must not be null * @return the period in minutes * @throws IllegalArgumentException if the instants are null or invalid */ public static Minutes minutesBetween(ReadableInstant start, ReadableInstant end) { int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.minutes()); return Minutes.minutes(amount); }
/** * Returns a new instance with the specified number of minutes added. * <p> * This instance is immutable and unaffected by this method call. * * @param minutes the amount of minutes to add, may be negative * @return the new period plus the specified number of minutes * @throws ArithmeticException if the result overflows an int */ public Minutes plus(int minutes) { if (minutes == 0) { return this; } return Minutes.minutes(FieldUtils.safeAdd(getValue(), minutes)); }
/** * Converts this period in hours to a period in minutes assuming a * 60 minute hour. * <p> * This method allows you to convert between different types of period. * However to achieve this it makes the assumption that all hours are 60 minutes long. * This may not be true for some unusual chronologies. However, it is included * as it is a useful operation for many applications and business rules. * * @return a period representing the number of minutes for this number of hours * @throws ArithmeticException if the number of minutes is too large to be represented */ public Minutes toStandardMinutes() { return Minutes.minutes(FieldUtils.safeMultiply(getValue(), DateTimeConstants.MINUTES_PER_HOUR)); }
/** * 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 period in hours to a period in minutes assuming a * 60 minute hour. * <p> * This method allows you to convert between different types of period. * However to achieve this it makes the assumption that all hours are 60 minutes long. * This may not be true for some unusual chronologies. However, it is included * as it is a useful operation for many applications and business rules. * * @return a period representing the number of minutes for this number of hours * @throws ArithmeticException if the number of minutes is too large to be represented */ public Minutes toStandardMinutes() { return Minutes.minutes(FieldUtils.safeMultiply(getValue(), DateTimeConstants.MINUTES_PER_HOUR)); }
/** * Creates a <code>Minutes</code> representing the number of whole minutes * in the specified interval. * * @param interval the interval to extract minutes from, null returns zero * @return the period in minutes * @throws IllegalArgumentException if the partials are null or invalid */ public static Minutes minutesIn(ReadableInterval interval) { if (interval == null) { return Minutes.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.minutes()); return Minutes.minutes(amount); }
/** * Creates a <code>Minutes</code> representing the number of whole minutes * in the specified interval. * * @param interval the interval to extract minutes from, null returns zero * @return the period in minutes * @throws IllegalArgumentException if the partials are null or invalid */ public static Minutes minutesIn(ReadableInterval interval) { if (interval == null) { return Minutes.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.minutes()); return Minutes.minutes(amount); }
@Test public void testIterable15MinuteSimple() { final DateTime baseTime = DateTimes.of("2011-01-01T09:30:00.000Z"); assertSameInterval( Lists.newArrayList( DateTimes.of("2011-01-01T09:30:00.000Z"), DateTimes.of("2011-01-01T09:45:00.000Z"), DateTimes.of("2011-01-01T10:00:00.000Z") ), Granularities.FIFTEEN_MINUTE.getIterable(new Interval(baseTime, baseTime.plus(Minutes.minutes(45)))) ); }
@Test public void testIterable15MinuteComplex() { final DateTime baseTime = DateTimes.of("2011-01-01T09:38:02.992Z"); assertSameInterval( Lists.newArrayList( DateTimes.of("2011-01-01T09:30:00.000Z"), DateTimes.of("2011-01-01T09:45:00.000Z"), DateTimes.of("2011-01-01T10:00:00.000Z"), DateTimes.of("2011-01-01T10:15:00.000Z") ), Granularities.FIFTEEN_MINUTE.getIterable(new Interval(baseTime, baseTime.plus(Minutes.minutes(45)))) ); }