/** * Converts this object to a LocalDate with the same year-month and chronology. * * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO * @return a LocalDate with the same year-month and chronology, never null */ public LocalDate toLocalDate(int dayOfMonth) { return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology()); }
/** * Converts this object to a LocalDate with the same year-month and chronology. * * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO * @return a LocalDate with the same year-month and chronology, never null */ public LocalDate toLocalDate(int dayOfMonth) { return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology()); }
/** * Handle broken serialization from other tools. * @return the resolved object, not null */ private Object readResolve() { if (DateTimeZone.UTC.equals(getChronology().getZone()) == false) { return new YearMonth(this, getChronology().withUTC()); } return this; }
/** * Handle broken serialization from other tools. * @return the resolved object, not null */ private Object readResolve() { if (DateTimeZone.UTC.equals(getChronology().getZone()) == false) { return new YearMonth(this, getChronology().withUTC()); } return this; }
/** * Returns a copy of this year-month with the month of year field updated. * <p> * YearMonth 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, never null * @throws IllegalArgumentException if the value is invalid */ public YearMonth withMonthOfYear(int monthOfYear) { int[] newValues = getValues(); newValues = getChronology().monthOfYear().set(this, MONTH_OF_YEAR, newValues, monthOfYear); return new YearMonth(this, newValues); }
/** * Returns a copy of this year-month with the year field updated. * <p> * YearMonth 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, never null * @throws IllegalArgumentException if the value is invalid */ public YearMonth withYear(int year) { int[] newValues = getValues(); newValues = getChronology().year().set(this, YEAR, newValues, year); return new YearMonth(this, newValues); }
/** * Returns a copy of this year-month with the year field updated. * <p> * YearMonth 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, never null * @throws IllegalArgumentException if the value is invalid */ public YearMonth withYear(int year) { int[] newValues = getValues(); newValues = getChronology().year().set(this, YEAR, newValues, year); return new YearMonth(this, newValues); }
/** * Returns a copy of this year-month with the month of year field updated. * <p> * YearMonth 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, never null * @throws IllegalArgumentException if the value is invalid */ public YearMonth withMonthOfYear(int monthOfYear) { int[] newValues = getValues(); newValues = getChronology().monthOfYear().set(this, MONTH_OF_YEAR, newValues, monthOfYear); return new YearMonth(this, newValues); }
/** * Returns a copy of this year-month with the specified chronology. * This instance is immutable and unaffected by this method call. * <p> * This method retains the values of the fields, thus the result will * typically refer to a different instant. * <p> * The time zone of the specified chronology is ignored, as YearMonth * operates without a time zone. * * @param newChronology the new chronology, null means ISO * @return a copy of this year-month with a different chronology, never null * @throws IllegalArgumentException if the values are invalid for the new chronology */ public YearMonth withChronologyRetainFields(Chronology newChronology) { newChronology = DateTimeUtils.getChronology(newChronology); newChronology = newChronology.withUTC(); if (newChronology == getChronology()) { return this; } else { YearMonth newYearMonth = new YearMonth(this, newChronology); newChronology.validate(newYearMonth, getValues()); return newYearMonth; } }
/** * Returns a copy of this year-month with the specified chronology. * This instance is immutable and unaffected by this method call. * <p> * This method retains the values of the fields, thus the result will * typically refer to a different instant. * <p> * The time zone of the specified chronology is ignored, as YearMonth * operates without a time zone. * * @param newChronology the new chronology, null means ISO * @return a copy of this year-month with a different chronology, never null * @throws IllegalArgumentException if the values are invalid for the new chronology */ public YearMonth withChronologyRetainFields(Chronology newChronology) { newChronology = DateTimeUtils.getChronology(newChronology); newChronology = newChronology.withUTC(); if (newChronology == getChronology()) { return this; } else { YearMonth newYearMonth = new YearMonth(this, newChronology); newChronology.validate(newYearMonth, getValues()); return newYearMonth; } }
/** * Converts this object to a LocalDate with the same year-month and chronology. * * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO * @return a LocalDate with the same year-month and chronology, never null */ public LocalDate toLocalDate(int dayOfMonth) { return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology()); }
/** * Handle broken serialization from other tools. * @return the resolved object, not null */ private Object readResolve() { if (DateTimeZone.UTC.equals(getChronology().getZone()) == false) { return new YearMonth(this, getChronology().withUTC()); } return this; }
/** * Returns a copy of this year-month with the month of year field updated. * <p> * YearMonth 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, never null * @throws IllegalArgumentException if the value is invalid */ public YearMonth withMonthOfYear(int monthOfYear) { int[] newValues = getValues(); newValues = getChronology().monthOfYear().set(this, MONTH_OF_YEAR, newValues, monthOfYear); return new YearMonth(this, newValues); }
/** * Returns a copy of this year-month with the year field updated. * <p> * YearMonth 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, never null * @throws IllegalArgumentException if the value is invalid */ public YearMonth withYear(int year) { int[] newValues = getValues(); newValues = getChronology().year().set(this, YEAR, newValues, year); return new YearMonth(this, newValues); }
/** * Returns a copy of this year-month with the specified chronology. * This instance is immutable and unaffected by this method call. * <p> * This method retains the values of the fields, thus the result will * typically refer to a different instant. * <p> * The time zone of the specified chronology is ignored, as YearMonth * operates without a time zone. * * @param newChronology the new chronology, null means ISO * @return a copy of this year-month with a different chronology, never null * @throws IllegalArgumentException if the values are invalid for the new chronology */ public YearMonth withChronologyRetainFields(Chronology newChronology) { newChronology = DateTimeUtils.getChronology(newChronology); newChronology = newChronology.withUTC(); if (newChronology == getChronology()) { return this; } else { YearMonth newYearMonth = new YearMonth(this, newChronology); newChronology.validate(newYearMonth, getValues()); return newYearMonth; } }
/** * Converts this object to a LocalDate with the same year-month and chronology. * * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO * @return a LocalDate with the same year-month and chronology, never null */ public LocalDate toLocalDate(int dayOfMonth) { return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology()); }
/** * Converts this object to a LocalDate with the same year-month and chronology. * * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO * @return a LocalDate with the same year-month and chronology, never null */ public LocalDate toLocalDate(int dayOfMonth) { return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology()); }
/** * Converts this object to a LocalDate with the same year-month and chronology. * * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO * @return a LocalDate with the same year-month and chronology, never null */ public LocalDate toLocalDate(int dayOfMonth) { return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology()); }
/** * Converts this object to a LocalDate with the same year-month and chronology. * * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO * @return a LocalDate with the same year-month and chronology, never null */ public LocalDate toLocalDate(int dayOfMonth) { return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology()); }
/** * Handle broken serialization from other tools. * @return the resolved object, not null */ private Object readResolve() { if (DateTimeZone.UTC.equals(getChronology().getZone()) == false) { return new YearMonth(this, getChronology().withUTC()); } return this; }