/** * Gets the duration field type, which is <code>days</code>. * * @return the period type */ public DurationFieldType getFieldType() { return DurationFieldType.days(); }
/** * Gets the duration field type, which is <code>days</code>. * * @return the period type */ public DurationFieldType getFieldType() { return DurationFieldType.days(); }
/** * Get the days duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField days() { return UnsupportedDurationField.getInstance(DurationFieldType.days()); }
/** * Adds the specified days to the number of days in the period. * * @param days the number of days * @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 addDays(int days) { super.addField(DurationFieldType.days(), days); }
/** * Sets the number of days of the period. * * @param days the number of days * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setDays(int days) { super.setField(DurationFieldType.days(), days); }
/** * Sets the number of days of the period. * * @param days the number of days * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setDays(int days) { super.setField(DurationFieldType.days(), days); }
/** * Adds the specified days to the number of days in the period. * * @param days the number of days * @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 addDays(int days) { super.addField(DurationFieldType.days(), days); }
/** * Get the days duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField days() { return UnsupportedDurationField.getInstance(DurationFieldType.days()); }
/** * Gets a type that defines just the days field. * * @return the period type */ public static PeriodType days() { PeriodType type = cDays; if (type == null) { type = new PeriodType( "Days", new DurationFieldType[] { DurationFieldType.days() }, new int[] { -1, -1, -1, 0, -1, -1, -1, -1, } ); cDays = type; } return type; }
/** * Gets a type that defines just the days field. * * @return the period type */ public static PeriodType days() { PeriodType type = cDays; if (type == null) { type = new PeriodType( "Days", new DurationFieldType[] { DurationFieldType.days() }, new int[] { -1, -1, -1, 0, -1, -1, -1, -1, } ); cDays = type; } return type; }
/** * Creates a <code>Days</code> representing the number of whole days * between the two specified datetimes. This method correctly handles * any daylight savings time changes that may occur during the interval. * * @param start the start instant, must not be null * @param end the end instant, must not be null * @return the period in days * @throws IllegalArgumentException if the instants are null or invalid */ public static Days daysBetween(ReadableInstant start, ReadableInstant end) { int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.days()); return Days.days(amount); }
/** * Creates a <code>Days</code> representing the number of whole days * between the two specified datetimes. This method correctly handles * any daylight savings time changes that may occur during the interval. * * @param start the start instant, must not be null * @param end the end instant, must not be null * @return the period in days * @throws IllegalArgumentException if the instants are null or invalid */ public static Days daysBetween(ReadableInstant start, ReadableInstant end) { int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.days()); return Days.days(amount); }
/** * Returns a copy of this date minus the specified number of days. * <p> * This datetime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * YearMonthDay subtracted = dt.minusDays(6); * YearMonthDay subtracted = dt.minus(Period.days(6)); * YearMonthDay subtracted = dt.withFieldAdded(DurationFieldType.days(), -6); * </pre> * * @param days the amount of days to subtract, may be negative * @return the new datetime minus the increased days * @since 1.1 */ public YearMonthDay minusDays(int days) { return withFieldAdded(DurationFieldType.days(), FieldUtils.safeNegate(days)); }
/** * Creates a <code>Days</code> representing the number of whole days * 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 days from, null returns zero * @return the period in days * @throws IllegalArgumentException if the partials are null or invalid */ public static Days daysIn(ReadableInterval interval) { if (interval == null) { return Days.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.days()); return Days.days(amount); }
/** * Creates a <code>Days</code> representing the number of whole days * 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 days from, null returns zero * @return the period in days * @throws IllegalArgumentException if the partials are null or invalid */ public static Days daysIn(ReadableInterval interval) { if (interval == null) { return Days.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.days()); return Days.days(amount); }
/** * Checks if the field type specified is supported by this * local time and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } if (isSupported(type.getDurationType()) == false) { return false; } DurationFieldType range = type.getRangeDurationType(); return (isSupported(range) || range == DurationFieldType.days()); }
/** * Converts this object to an <code>Interval</code> encompassing * the whole of this day. * <p> * The interval starts at midnight 00:00 and ends at 00:00 the following day, * (which is not included in the interval, as intervals are half-open). * * @return an interval over the day */ public Interval toInterval() { Chronology chrono = getChronology(); long start = getMillis(); long end = DurationFieldType.days().getField(chrono).add(start, 1); return new Interval(start, end, chrono); }
/** * Converts this object to an <code>Interval</code> encompassing * the whole of this day. * <p> * The interval starts at midnight 00:00 and ends at 00:00 the following day, * (which is not included in the interval, as intervals are half-open). * * @return an interval over the day */ public Interval toInterval() { Chronology chrono = getChronology(); long start = getMillis(); long end = DurationFieldType.days().getField(chrono).add(start, 1); return new Interval(start, end, chrono); }
/** * 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; }