/** * Rounds to the lowest whole unit of this field on a copy of this DateTime. * * @return a copy of the DateTime with the field value changed */ public DateTime roundFloorCopy() { return iInstant.withMillis(iField.roundFloor(iInstant.getMillis())); }
/** * Set the time from milliseconds. * The date part of this object will be unaffected. * * @param millis an instant to copy the time from, date part ignored * @throws IllegalArgumentException if the value is invalid */ public void setTime(final long millis) { int millisOfDay = ISOChronology.getInstanceUTC().millisOfDay().get(millis); setMillis(getChronology().millisOfDay().set(getMillis(), millisOfDay)); }
/** * Construct a RemainderDateTimeField that compliments the given * DividedDateTimeField. * * @param dividedField complimentary divided field, like "century()". * @param type the field type this field actually uses */ public RemainderDateTimeField(DividedDateTimeField dividedField, DateTimeFieldType type) { this(dividedField, dividedField.getWrappedField().getDurationField(), type); }
private String print(long instant, Chronology chrono, Locale locale) { DateTimeField field = iFieldType.getField(chrono); if (iShort) { return field.getAsShortText(instant, locale); } else { return field.getAsText(instant, locale); } }
private String print(ReadablePartial partial, Locale locale) { if (partial.isSupported(iFieldType)) { DateTimeField field = iFieldType.getField(partial.getChronology()); if (iShort) { return field.getAsShortText(partial, locale); } else { return field.getAsText(partial, locale); } } else { return "\ufffd"; } }
public int getMaximumValue(ReadablePartial partial, int[] values) { Chronology chrono = GJChronology.getInstanceUTC(); long instant = 0L; for (int i = 0, isize = partial.size(); i < isize; i++) { DateTimeField field = partial.getFieldType(i).getField(chrono); if (values[i] <= field.getMaximumValue(instant)) { instant = field.set(instant, values[i]); } } return getMaximumValue(instant); }
/** * Returns a copy of this datetime with the month of year field updated. * <p> * DateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * month of year changed. * * @param monthOfYear the month of year to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateTime withMonthOfYear(int monthOfYear) { return withMillis(getChronology().monthOfYear().set(getMillis(), monthOfYear)); }
/** * Returns a copy of this datetime with the year field updated. * <p> * DateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * year changed. * * @param year the year to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateTime withYear(int year) { return withMillis(getChronology().year().set(getMillis(), year)); }
/** * Returns a copy of this datetime with the day of week field updated. * <p> * DateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * day of week changed. * * @param dayOfWeek the day of week to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateTime withDayOfWeek(int dayOfWeek) { return withMillis(getChronology().dayOfWeek().set(getMillis(), dayOfWeek)); }
/** * Returns a copy of this datetime with the year of century field updated. * <p> * DateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * year of century changed. * * @param yearOfCentury the year of century to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateTime withYearOfCentury(int yearOfCentury) { return withMillis(getChronology().yearOfCentury().set(getMillis(), yearOfCentury)); }
/** * Returns a copy of this datetime with the millis of day field updated. * <p> * DateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * millis of day changed. * * @param millis the millis of day to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateTime withMillisOfDay(int millis) { return withMillis(getChronology().millisOfDay().set(getMillis(), millis)); }
/** * Returns a copy of this datetime with the era field updated. * <p> * DateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * era changed. * * @param era the era to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateTime withEra(int era) { return withMillis(getChronology().era().set(getMillis(), era)); }
/** * Returns a copy of this datetime with the year of era field updated. * <p> * DateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * year of era changed. * * @param yearOfEra the year of era to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid * @since 1.3 */ public DateTime withYearOfEra(int yearOfEra) { return withMillis(getChronology().yearOfEra().set(getMillis(), yearOfEra)); }
/** * Rounds to the highest whole unit of this field on a copy of this DateTime. * * @return a copy of the DateTime with the field value changed */ public DateTime roundCeilingCopy() { return iInstant.withMillis(iField.roundCeiling(iInstant.getMillis())); }
/** * Set the month of the year to the specified value. * * @param monthOfYear the month of the year * @throws IllegalArgumentException if the value is invalid */ public void setMonthOfYear(final int monthOfYear) { setMillis(getChronology().monthOfYear().set(getMillis(), monthOfYear)); }
/** * Set the hour of the day to the specified value. * * @param hourOfDay the hour of day * @throws IllegalArgumentException if the value is invalid */ public void setHourOfDay(final int hourOfDay) { setMillis(getChronology().hourOfDay().set(getMillis(), hourOfDay)); }
/** * Set the minute of the hour to the specified value. * * @param minuteOfHour the minute of hour * @throws IllegalArgumentException if the value is invalid */ public void setMinuteOfHour(final int minuteOfHour) { setMillis(getChronology().minuteOfHour().set(getMillis(), minuteOfHour)); }
/** * Set the second of the day to the specified value. * <p> * Setting this will replace the values of second-of-minute, minute-of-hour and hour-of-day. * * @param secondOfDay the second of day * @throws IllegalArgumentException if the value is invalid */ public void setSecondOfDay(final int secondOfDay) { setMillis(getChronology().secondOfDay().set(getMillis(), secondOfDay)); }
/** * Get the month of year field value. * * @return the month of year */ public int getMonthOfYear() { return getChronology().monthOfYear().get(getLocalMillis()); }
protected void assemble(Fields fields) { if (getBase().getZone() == DateTimeZone.UTC) { // Use zero based century and year of century. fields.centuryOfEra = new DividedDateTimeField( ISOYearOfEraDateTimeField.INSTANCE, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField(); fields.yearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, DateTimeFieldType.yearOfCentury()); fields.weekyearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, fields.weekyears, DateTimeFieldType.weekyearOfCentury()); } }