/** * Gets the duration field type, which is <code>seconds</code>. * * @return the period type */ public DurationFieldType getFieldType() { return DurationFieldType.seconds(); }
/** * Gets the duration field type, which is <code>seconds</code>. * * @return the period type */ public DurationFieldType getFieldType() { return DurationFieldType.seconds(); }
/** * Get the seconds duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField seconds() { return UnsupportedDurationField.getInstance(DurationFieldType.seconds()); }
/** * Adds the specified seconds to the number of seconds in the period. * * @param seconds the number of seconds * @throws IllegalArgumentException if field is not supported and the value is non-zero * @throws ArithmeticException if the addition exceeds the capacity of the period */ public void addSeconds(int seconds) { super.addField(DurationFieldType.seconds(), seconds); }
/** * Sets the number of seconds of the period. * * @param seconds the number of seconds * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setSeconds(int seconds) { super.setField(DurationFieldType.seconds(), seconds); }
/** * Sets the number of seconds of the period. * * @param seconds the number of seconds * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setSeconds(int seconds) { super.setField(DurationFieldType.seconds(), seconds); }
/** * Adds the specified seconds to the number of seconds in the period. * * @param seconds the number of seconds * @throws IllegalArgumentException if field is not supported and the value is non-zero * @throws ArithmeticException if the addition exceeds the capacity of the period */ public void addSeconds(int seconds) { super.addField(DurationFieldType.seconds(), seconds); }
/** * Get the seconds duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField seconds() { return UnsupportedDurationField.getInstance(DurationFieldType.seconds()); }
/** * Gets a type that defines just the seconds field. * * @return the period type */ public static PeriodType seconds() { PeriodType type = cSeconds; if (type == null) { type = new PeriodType( "Seconds", new DurationFieldType[] { DurationFieldType.seconds() }, new int[] { -1, -1, -1, -1, -1, -1, 0, -1, } ); cSeconds = type; } return type; }
/** * Returns a copy of this time plus the specified number of seconds. * <p> * This time instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * TimeOfDay added = dt.plusSeconds(6); * TimeOfDay added = dt.plus(Period.seconds(6)); * TimeOfDay added = dt.withFieldAdded(DurationFieldType.seconds(), 6); * </pre> * * @param seconds the amount of seconds to add, may be negative * @return the new time plus the increased seconds * @since 1.1 */ public TimeOfDay plusSeconds(int seconds) { return withFieldAdded(DurationFieldType.seconds(), seconds); }
/** * Gets a type that defines just the seconds field. * * @return the period type */ public static PeriodType seconds() { PeriodType type = cSeconds; if (type == null) { type = new PeriodType( "Seconds", new DurationFieldType[] { DurationFieldType.seconds() }, new int[] { -1, -1, -1, -1, -1, -1, 0, -1, } ); cSeconds = type; } return type; }
/** * Returns a copy of this time plus the specified number of seconds. * <p> * This time instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * TimeOfDay added = dt.plusSeconds(6); * TimeOfDay added = dt.plus(Period.seconds(6)); * TimeOfDay added = dt.withFieldAdded(DurationFieldType.seconds(), 6); * </pre> * * @param seconds the amount of seconds to add, may be negative * @return the new time plus the increased seconds * @since 1.1 */ public TimeOfDay plusSeconds(int seconds) { return withFieldAdded(DurationFieldType.seconds(), seconds); }
/** * Creates a <code>Seconds</code> representing the number of whole seconds * 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 seconds * @throws IllegalArgumentException if the instants are null or invalid */ public static Seconds secondsBetween(ReadableInstant start, ReadableInstant end) { int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.seconds()); return Seconds.seconds(amount); }
/** * Creates a <code>Seconds</code> representing the number of whole seconds * 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 seconds * @throws IllegalArgumentException if the instants are null or invalid */ public static Seconds secondsBetween(ReadableInstant start, ReadableInstant end) { int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.seconds()); return Seconds.seconds(amount); }
/** * Returns a copy of this time minus the specified number of seconds. * <p> * This time instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * TimeOfDay subtracted = dt.minusSeconds(6); * TimeOfDay subtracted = dt.minus(Period.seconds(6)); * TimeOfDay subtracted = dt.withFieldAdded(DurationFieldType.seconds(), -6); * </pre> * * @param seconds the amount of seconds to subtract, may be negative * @return the new time minus the increased seconds * @since 1.1 */ public TimeOfDay minusSeconds(int seconds) { return withFieldAdded(DurationFieldType.seconds(), FieldUtils.safeNegate(seconds)); }
/** * Returns a copy of this time minus the specified number of seconds. * <p> * This time instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * TimeOfDay subtracted = dt.minusSeconds(6); * TimeOfDay subtracted = dt.minus(Period.seconds(6)); * TimeOfDay subtracted = dt.withFieldAdded(DurationFieldType.seconds(), -6); * </pre> * * @param seconds the amount of seconds to subtract, may be negative * @return the new time minus the increased seconds * @since 1.1 */ public TimeOfDay minusSeconds(int seconds) { return withFieldAdded(DurationFieldType.seconds(), FieldUtils.safeNegate(seconds)); }
/** * Creates a <code>Seconds</code> representing the number of whole seconds * in the specified interval. * * @param interval the interval to extract seconds from, null returns zero * @return the period in seconds * @throws IllegalArgumentException if the partials are null or invalid */ public static Seconds secondsIn(ReadableInterval interval) { if (interval == null) { return Seconds.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.seconds()); return Seconds.seconds(amount); }
/** * Creates a <code>Seconds</code> representing the number of whole seconds * in the specified interval. * * @param interval the interval to extract seconds from, null returns zero * @return the period in seconds * @throws IllegalArgumentException if the partials are null or invalid */ public static Seconds secondsIn(ReadableInterval interval) { if (interval == null) { return Seconds.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.seconds()); return Seconds.seconds(amount); }
/** * Private method called from constructor. */ private int[] setPeriodInternal(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis) { int[] newValues = new int[size()]; checkAndUpdate(DurationFieldType.years(), newValues, years); checkAndUpdate(DurationFieldType.months(), newValues, months); checkAndUpdate(DurationFieldType.weeks(), newValues, weeks); checkAndUpdate(DurationFieldType.days(), newValues, days); checkAndUpdate(DurationFieldType.hours(), newValues, hours); checkAndUpdate(DurationFieldType.minutes(), newValues, minutes); checkAndUpdate(DurationFieldType.seconds(), newValues, seconds); checkAndUpdate(DurationFieldType.millis(), newValues, millis); return newValues; }
/** * Private method called from constructor. */ private int[] setPeriodInternal(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis) { int[] newValues = new int[size()]; checkAndUpdate(DurationFieldType.years(), newValues, years); checkAndUpdate(DurationFieldType.months(), newValues, months); checkAndUpdate(DurationFieldType.weeks(), newValues, weeks); checkAndUpdate(DurationFieldType.days(), newValues, days); checkAndUpdate(DurationFieldType.hours(), newValues, hours); checkAndUpdate(DurationFieldType.minutes(), newValues, minutes); checkAndUpdate(DurationFieldType.seconds(), newValues, seconds); checkAndUpdate(DurationFieldType.millis(), newValues, millis); return newValues; }