/** * Gets the duration field type, which is <code>weeks</code>. * * @return the period type */ public DurationFieldType getFieldType() { return DurationFieldType.weeks(); }
public DurationFieldType getDurationType() { return DurationFieldType.weeks(); }
/** * Gets the duration field type, which is <code>weeks</code>. * * @return the period type */ public DurationFieldType getFieldType() { return DurationFieldType.weeks(); }
/** * Sets the number of weeks of the period. * * @param weeks the number of weeks * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setWeeks(int weeks) { super.setField(DurationFieldType.weeks(), weeks); }
/** * Get the weeks duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField weeks() { return UnsupportedDurationField.getInstance(DurationFieldType.weeks()); }
/** * Adds the specified weeks to the number of weeks in the period. * * @param weeks the number of weeks * @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 addWeeks(int weeks) { super.addField(DurationFieldType.weeks(), weeks); }
/** * Sets the number of weeks of the period. * * @param weeks the number of weeks * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setWeeks(int weeks) { super.setField(DurationFieldType.weeks(), weeks); }
/** * Adds the specified weeks to the number of weeks in the period. * * @param weeks the number of weeks * @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 addWeeks(int weeks) { super.addField(DurationFieldType.weeks(), weeks); }
/** * Get the weeks duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField weeks() { return UnsupportedDurationField.getInstance(DurationFieldType.weeks()); }
/** * Gets a type that defines just the weeks field. * * @return the period type */ public static PeriodType weeks() { PeriodType type = cWeeks; if (type == null) { type = new PeriodType( "Weeks", new DurationFieldType[] { DurationFieldType.weeks() }, new int[] { -1, -1, 0, -1, -1, -1, -1, -1, } ); cWeeks = type; } return type; }
/** * Gets a type that defines just the weeks field. * * @return the period type */ public static PeriodType weeks() { PeriodType type = cWeeks; if (type == null) { type = new PeriodType( "Weeks", new DurationFieldType[] { DurationFieldType.weeks() }, new int[] { -1, -1, 0, -1, -1, -1, -1, -1, } ); cWeeks = type; } return type; }
/** * Creates a <code>Weeks</code> representing the number of whole weeks * 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 weeks * @throws IllegalArgumentException if the instants are null or invalid */ public static Weeks weeksBetween(ReadableInstant start, ReadableInstant end) { int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.weeks()); return Weeks.weeks(amount); }
/** * Creates a <code>Weeks</code> representing the number of whole weeks * 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 weeks * @throws IllegalArgumentException if the instants are null or invalid */ public static Weeks weeksBetween(ReadableInstant start, ReadableInstant end) { int amount = BaseSingleFieldPeriod.between(start, end, DurationFieldType.weeks()); return Weeks.weeks(amount); }
@Override public long fromMillis(long millisSinceEpoch) { return DurationFieldType.weeks().getField(ISOChronology.getInstanceUTC()).getDifference(millisSinceEpoch, 0L); } },
@Override long fromMillis(long millisSinceEpoch) { return DurationFieldType.weeks().getField(ISOChronology.getInstanceUTC()).getDifference(millisSinceEpoch, 0L); } }, MONTHS {
/** * Creates a <code>Weeks</code> representing the number of whole weeks * in the specified interval. * * @param interval the interval to extract weeks from, null returns zero * @return the period in weeks * @throws IllegalArgumentException if the partials are null or invalid */ public static Weeks weeksIn(ReadableInterval interval) { if (interval == null) { return Weeks.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.weeks()); return Weeks.weeks(amount); }
/** * Creates a <code>Weeks</code> representing the number of whole weeks * in the specified interval. * * @param interval the interval to extract weeks from, null returns zero * @return the period in weeks * @throws IllegalArgumentException if the partials are null or invalid */ public static Weeks weeksIn(ReadableInterval interval) { if (interval == null) { return Weeks.ZERO; } int amount = BaseSingleFieldPeriod.between(interval.getStart(), interval.getEnd(), DurationFieldType.weeks()); return Weeks.weeks(amount); }
@Override public PartialTime reduceGranularityTo(Duration granularity) { Partial pbase = base; if (JodaTimeUtils.hasField(granularity.getJodaTimePeriod(), DurationFieldType.weeks())) { // Make sure the partial time has weeks in it if (!JodaTimeUtils.hasField(pbase, DateTimeFieldType.weekOfWeekyear())) { // Add week year to it pbase = JodaTimeUtils.resolveWeek(pbase); } } Partial p = JodaTimeUtils.discardMoreSpecificFields( pbase, JodaTimeUtils.getMostSpecific(granularity.getJodaTimePeriod()) ); return new PartialTime(this,p); }
/** * 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; }