/** * Gets the duration field type, which is <code>months</code>. * * @return the period type */ public DurationFieldType getFieldType() { return DurationFieldType.months(); }
public DurationFieldType getDurationType() { return DurationFieldType.months(); }
public DurationFieldType getRangeDurationType() { return DurationFieldType.months(); }
/** * Gets the duration field type, which is <code>months</code>. * * @return the period type */ public DurationFieldType getFieldType() { return DurationFieldType.months(); }
public DurationFieldType getDurationType() { return DurationFieldType.months(); }
/** * Get the months duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField months() { return UnsupportedDurationField.getInstance(DurationFieldType.months()); }
/** * Sets the number of months of the period. * * @param months the number of months * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setMonths(int months) { super.setField(DurationFieldType.months(), months); }
/** * Adds the specified months to the number of months in the period. * * @param months the number of months * @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 addMonths(int months) { super.addField(DurationFieldType.months(), months); }
/** * Sets the number of months of the period. * * @param months the number of months * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setMonths(int months) { super.setField(DurationFieldType.months(), months); }
/** * Get the months duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField months() { return UnsupportedDurationField.getInstance(DurationFieldType.months()); }
/** * Adds the specified months to the number of months in the period. * * @param months the number of months * @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 addMonths(int months) { super.addField(DurationFieldType.months(), months); }
/** * Returns a copy of this year-month plus the specified number of months. * <p> * This year-month instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * YearMonth added = ym.plusMonths(6); * YearMonth added = ym.plus(Period.months(6)); * YearMonth added = ym.withFieldAdded(DurationFieldType.months(), 6); * </pre> * * @param months the amount of months to add, may be negative * @return the new year-month plus the increased months, never null */ public YearMonth plusMonths(int months) { return withFieldAdded(DurationFieldType.months(), months); }
/** * Gets a type that defines just the months field. * * @return the period type */ public static PeriodType months() { PeriodType type = cMonths; if (type == null) { type = new PeriodType( "Months", new DurationFieldType[] { DurationFieldType.months() }, new int[] { -1, 0, -1, -1, -1, -1, -1, -1, } ); cMonths = type; } return type; }
/** * Returns a copy of this year-month minus the specified number of months. * <p> * This year-month instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * YearMonth subtracted = ym.minusMonths(6); * YearMonth subtracted = ym.minus(Period.months(6)); * YearMonth subtracted = ym.withFieldAdded(DurationFieldType.months(), -6); * </pre> * * @param months the amount of months to subtract, may be negative * @return the new year-month minus the increased months, never null */ public YearMonth minusMonths(int months) { return withFieldAdded(DurationFieldType.months(), FieldUtils.safeNegate(months)); }
/** * Creates a <code>Months</code> representing the number of whole months * between the two specified datetimes. This method correctly handles * any daylight savings time changes that may occur during the interval. * <p> * This method calculates by adding months to the start date until the result * is past the end date. As such, a period from the end of a "long" month to * the end of a "short" month is counted as a whole month. * * @param start the start instant, must not be null * @param end the end instant, must not be null * @return the period in months * @throws IllegalArgumentException if the instants are null or invalid */ public static Months monthsBetween(ReadableInstant start, ReadableInstant end) { int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.months()); return Months.months(amount); }
@Override public long fromMillis(long millisSinceEpoch) { return DurationFieldType.months().getField(ISOChronology.getInstanceUTC()).getDifference(millisSinceEpoch, 0L); } },
@Override long fromMillis(long millisSinceEpoch) { return DurationFieldType.months().getField(ISOChronology.getInstanceUTC()).getDifference(millisSinceEpoch, 0L); } }, YEARS {
/** * Creates a <code>Months</code> representing the number of whole months * in the specified interval. This method correctly handles any daylight * savings time changes that may occur during the interval. * * @param interval the interval to extract months from, null returns zero * @return the period in months * @throws IllegalArgumentException if the partials are null or invalid */ public static Months monthsIn(ReadableInterval interval) { if (interval == null) { return Months.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.months()); return Months.months(amount); }
/** * Creates a <code>Months</code> representing the number of whole months * in the specified interval. This method correctly handles any daylight * savings time changes that may occur during the interval. * * @param interval the interval to extract months from, null returns zero * @return the period in months * @throws IllegalArgumentException if the partials are null or invalid */ public static Months monthsIn(ReadableInterval interval) { if (interval == null) { return Months.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.months()); return Months.months(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; }