Refine search
/** * Returns a copy of this date with the partial set of fields replacing * those from this instance. * <p> * For example, if the partial contains a year and a month then those two * fields will be changed in the returned instance. * Unsupported fields are ignored. * If the partial is null, then <code>this</code> is returned. * * @param partial the partial set of fields to apply to this date, null ignored * @return a copy of this date with a different set of fields * @throws IllegalArgumentException if any value is invalid */ public LocalDate withFields(ReadablePartial partial) { if (partial == null) { return this; } return withLocalMillis(getChronology().set(partial, getLocalMillis())); }
/** * Get the era field value. * * @return the era */ public int getEra() { return getChronology().era().get(getLocalMillis()); }
/** * Returns a copy of this date with the partial set of fields replacing * those from this instance. * <p> * For example, if the partial contains a year and a month then those two * fields will be changed in the returned instance. * Unsupported fields are ignored. * If the partial is null, then <code>this</code> is returned. * * @param partial the partial set of fields to apply to this date, null ignored * @return a copy of this date with a different set of fields * @throws IllegalArgumentException if any value is invalid */ public LocalDate withFields(ReadablePartial partial) { if (partial == null) { return this; } return withLocalMillis(getChronology().set(partial, getLocalMillis())); }
/** * Get the year of century field value. * * @return the year of century */ public int getYearOfCentury() { return getChronology().yearOfCentury().get(getLocalMillis()); }
/** * Returns a copy of this date with the year field updated. * <p> * LocalDate 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 */ public LocalDate withYear(int year) { return withLocalMillis(getChronology().year().set(getLocalMillis(), year)); }
/** * Get the day of month field value. * <p> * The values for the day of month are defined in {@link org.joda.time.DateTimeConstants}. * * @return the day of month */ public int getDayOfMonth() { return getChronology().dayOfMonth().get(getLocalMillis()); }
/** * Returns a copy of this date with the day of year field updated. * <p> * LocalDate is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * day of year changed. * * @param dayOfYear the day of year to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDate withDayOfYear(int dayOfYear) { return withLocalMillis(getChronology().dayOfYear().set(getLocalMillis(), dayOfYear)); }
/** * Get the year field value. * * @return the year */ public int getYear() { return getChronology().year().get(getLocalMillis()); }
/** * Returns a copy of this date with the era field updated. * <p> * LocalDate 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 */ public LocalDate withEra(int era) { return withLocalMillis(getChronology().era().set(getLocalMillis(), era)); }
/** * Get the year of era field value. * * @return the year of era */ public int getCenturyOfEra() { return getChronology().centuryOfEra().get(getLocalMillis()); }
/** * Returns a copy of this date with the day of month field updated. * <p> * LocalDate is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * day of month changed. * * @param dayOfMonth the day of month to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDate withDayOfMonth(int dayOfMonth) { return withLocalMillis(getChronology().dayOfMonth().set(getLocalMillis(), dayOfMonth)); }
/** * Get the day of year field value. * * @return the day of year */ public int getDayOfYear() { return getChronology().dayOfYear().get(getLocalMillis()); }
/** * Returns a copy of this date with the century of era field updated. * <p> * LocalDate is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * century of era changed. * * @param centuryOfEra the century of era to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDate withCenturyOfEra(int centuryOfEra) { return withLocalMillis(getChronology().centuryOfEra().set(getLocalMillis(), centuryOfEra)); }
/** * Get the day of week field value. * <p> * The values for the day of week are defined in {@link org.joda.time.DateTimeConstants}. * * @return the day of week */ public int getDayOfWeek() { return getChronology().dayOfWeek().get(getLocalMillis()); }
/** * Returns a copy of this date with the year of era field updated. * <p> * LocalDate 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 */ public LocalDate withYearOfEra(int yearOfEra) { return withLocalMillis(getChronology().yearOfEra().set(getLocalMillis(), yearOfEra)); }
/** * Get the year of era field value. * * @return the year of era */ public int getYearOfEra() { return getChronology().yearOfEra().get(getLocalMillis()); }
/** * Returns a copy of this date with the year of century field updated. * <p> * LocalDate 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 */ public LocalDate withYearOfCentury(int yearOfCentury) { return withLocalMillis(getChronology().yearOfCentury().set(getLocalMillis(), yearOfCentury)); }
/** * Get the month of year field value. * * @return the month of year */ public int getMonthOfYear() { return getChronology().monthOfYear().get(getLocalMillis()); }
/** * Returns a copy of this date with the month of year field updated. * <p> * LocalDate 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 */ public LocalDate withMonthOfYear(int monthOfYear) { return withLocalMillis(getChronology().monthOfYear().set(getLocalMillis(), monthOfYear)); }
/** * Returns a copy of this date with different local millis. * <p> * The returned object will be a new instance of the same type. * Only the millis will change, the chronology is kept. * The returned object will be either be a new instance or <code>this</code>. * * @param newMillis the new millis, from 1970-01-01T00:00:00 * @return a copy of this date with different millis */ LocalDate withLocalMillis(long newMillis) { newMillis = iChronology.dayOfMonth().roundFloor(newMillis); return (newMillis == getLocalMillis() ? this : new LocalDate(newMillis, getChronology())); }