/** * Gets the maximum number of days in the month specified by the instant. * * @param instant millis from 1970-01-01T00:00:00Z * @return the maximum number of days in the month */ int getDaysInMonthMax(long instant) { int thisYear = getYear(instant); int thisMonth = getMonthOfYear(instant, thisYear); return getDaysInYearMonth(thisYear, thisMonth); }
/** * Gets the maximum number of days in the month specified by the instant. * * @param instant millis from 1970-01-01T00:00:00Z * @return the maximum number of days in the month */ int getDaysInMonthMax(long instant) { int thisYear = getYear(instant); int thisMonth = getMonthOfYear(instant, thisYear); return getDaysInYearMonth(thisYear, thisMonth); }
int maxDay = iChronology.getDaysInYearMonth(yearToUse, monthToUse); if (dayToUse > maxDay) { dayToUse = maxDay;
int maxDay = iChronology.getDaysInYearMonth(yearToUse, monthToUse); if (dayToUse > maxDay) { dayToUse = maxDay;
/** * Set the Month component of the specified time instant.<p> * If the new month has less total days than the specified * day of the month, this value is coerced to the nearest * sane value. e.g.<p> * 07-31 to month 6 = 06-30<p> * 03-31 to month 2 = 02-28 or 02-29 depending<p> * * @param instant the time instant in millis to update. * @param month the month (1,12) to update the time to. * @return the updated time instant. * @throws IllegalArgumentException if month is invalid */ public long set(long instant, int month) { FieldUtils.verifyValueBounds(this, month, MIN, iMax); // int thisYear = iChronology.getYear(instant); // int thisDom = iChronology.getDayOfMonth(instant, thisYear); int maxDom = iChronology.getDaysInYearMonth(thisYear, month); if (thisDom > maxDom) { // Quietly force DOM to nearest sane value. thisDom = maxDom; } // Return newly calculated millis value return iChronology.getYearMonthDayMillis(thisYear, month, thisDom) + iChronology.getMillisOfDay(instant); }
int maxDay = iChronology.getDaysInYearMonth(i_yearToUse, i_monthToUse); if (dayToUse > maxDay) { dayToUse = maxDay;
/** * Set the Month component of the specified time instant.<p> * If the new month has less total days than the specified * day of the month, this value is coerced to the nearest * sane value. e.g.<p> * 07-31 to month 6 = 06-30<p> * 03-31 to month 2 = 02-28 or 02-29 depending<p> * * @param instant the time instant in millis to update. * @param month the month (1,12) to update the time to. * @return the updated time instant. * @throws IllegalArgumentException if month is invalid */ public long set(long instant, int month) { FieldUtils.verifyValueBounds(this, month, MIN, iMax); // int thisYear = iChronology.getYear(instant); // int thisDom = iChronology.getDayOfMonth(instant, thisYear); int maxDom = iChronology.getDaysInYearMonth(thisYear, month); if (thisDom > maxDom) { // Quietly force DOM to nearest sane value. thisDom = maxDom; } // Return newly calculated millis value return iChronology.getYearMonthDayMillis(thisYear, month, thisDom) + iChronology.getMillisOfDay(instant); }
public int getMaximumValue(ReadablePartial partial, int[] values) { int size = partial.size(); for (int i = 0; i < size; i++) { if (partial.getFieldType(i) == DateTimeFieldType.monthOfYear()) { int month = values[i]; for (int j = 0; j < size; j++) { if (partial.getFieldType(j) == DateTimeFieldType.year()) { int year = values[j]; return iChronology.getDaysInYearMonth(year, month); } } return iChronology.getDaysInMonthMax(month); } } return getMaximumValue(); }
int maxDay = iChronology.getDaysInYearMonth(i_yearToUse, i_monthToUse); if (dayToUse > maxDay) { dayToUse = maxDay;
public int getMaximumValue(ReadablePartial partial, int[] values) { int size = partial.size(); for (int i = 0; i < size; i++) { if (partial.getFieldType(i) == DateTimeFieldType.monthOfYear()) { int month = values[i]; for (int j = 0; j < size; j++) { if (partial.getFieldType(j) == DateTimeFieldType.year()) { int year = values[j]; return iChronology.getDaysInYearMonth(year, month); } } return iChronology.getDaysInMonthMax(month); } } return getMaximumValue(); }
public int getMaximumValue(ReadablePartial partial) { if (partial.isSupported(DateTimeFieldType.monthOfYear())) { int month = partial.get(DateTimeFieldType.monthOfYear()); if (partial.isSupported(DateTimeFieldType.year())) { int year = partial.get(DateTimeFieldType.year()); return iChronology.getDaysInYearMonth(year, month); } return iChronology.getDaysInMonthMax(month); } return getMaximumValue(); }
public int getMaximumValue(ReadablePartial partial) { if (partial.isSupported(DateTimeFieldType.monthOfYear())) { int month = partial.get(DateTimeFieldType.monthOfYear()); if (partial.isSupported(DateTimeFieldType.year())) { int year = partial.get(DateTimeFieldType.year()); return iChronology.getDaysInYearMonth(year, month); } return iChronology.getDaysInMonthMax(month); } return getMaximumValue(); }
/** * Gets the milliseconds for a date at midnight. * * @param year the year * @param monthOfYear the month * @param dayOfMonth the day * @return the milliseconds */ long getDateMidnightMillis(int year, int monthOfYear, int dayOfMonth) { FieldUtils.verifyValueBounds(DateTimeFieldType.year(), year, getMinYear() - 1, getMaxYear() + 1); FieldUtils.verifyValueBounds(DateTimeFieldType.monthOfYear(), monthOfYear, 1, getMaxMonth(year)); FieldUtils.verifyValueBounds(DateTimeFieldType.dayOfMonth(), dayOfMonth, 1, getDaysInYearMonth(year, monthOfYear)); long instant = getYearMonthDayMillis(year, monthOfYear, dayOfMonth); // check for limit caused by min/max year +1/-1 if (instant < 0 && year == getMaxYear() + 1) { return Long.MAX_VALUE; } else if (instant > 0 && year == getMinYear() - 1) { return Long.MIN_VALUE; } return instant; }
/** * Gets the milliseconds for a date at midnight. * * @param year the year * @param monthOfYear the month * @param dayOfMonth the day * @return the milliseconds */ long getDateMidnightMillis(int year, int monthOfYear, int dayOfMonth) { FieldUtils.verifyValueBounds(DateTimeFieldType.year(), year, getMinYear() - 1, getMaxYear() + 1); FieldUtils.verifyValueBounds(DateTimeFieldType.monthOfYear(), monthOfYear, 1, getMaxMonth(year)); FieldUtils.verifyValueBounds(DateTimeFieldType.dayOfMonth(), dayOfMonth, 1, getDaysInYearMonth(year, monthOfYear)); long instant = getYearMonthDayMillis(year, monthOfYear, dayOfMonth); // check for limit caused by min/max year +1/-1 if (instant < 0 && year == getMaxYear() + 1) { return Long.MAX_VALUE; } else if (instant > 0 && year == getMinYear() - 1) { return Long.MIN_VALUE; } return instant; }
if (minuendDom == iChronology.getDaysInYearMonth(minuendYear, minuendMonth)) {
if (minuendDom == iChronology.getDaysInYearMonth(minuendYear, minuendMonth)) {
/** * Gets the maximum number of days in the month specified by the instant. * * @param instant millis from 1970-01-01T00:00:00Z * @return the maximum number of days in the month */ int getDaysInMonthMax(long instant) { int thisYear = getYear(instant); int thisMonth = getMonthOfYear(instant, thisYear); return getDaysInYearMonth(thisYear, thisMonth); }
public int getMaximumValue(ReadablePartial partial, int[] values) { int size = partial.size(); for (int i = 0; i < size; i++) { if (partial.getFieldType(i) == DateTimeFieldType.monthOfYear()) { int month = values[i]; for (int j = 0; j < size; j++) { if (partial.getFieldType(j) == DateTimeFieldType.year()) { int year = values[j]; return iChronology.getDaysInYearMonth(year, month); } } return iChronology.getDaysInMonthMax(month); } } return getMaximumValue(); }
public int getMaximumValue(ReadablePartial partial) { if (partial.isSupported(DateTimeFieldType.monthOfYear())) { int month = partial.get(DateTimeFieldType.monthOfYear()); if (partial.isSupported(DateTimeFieldType.year())) { int year = partial.get(DateTimeFieldType.year()); return iChronology.getDaysInYearMonth(year, month); } return iChronology.getDaysInMonthMax(month); } return getMaximumValue(); }
/** * Gets the milliseconds for a date at midnight. * * @param year the year * @param monthOfYear the month * @param dayOfMonth the day * @return the milliseconds */ long getDateMidnightMillis(int year, int monthOfYear, int dayOfMonth) { FieldUtils.verifyValueBounds(DateTimeFieldType.year(), year, getMinYear(), getMaxYear()); FieldUtils.verifyValueBounds(DateTimeFieldType.monthOfYear(), monthOfYear, 1, getMaxMonth(year)); FieldUtils.verifyValueBounds(DateTimeFieldType.dayOfMonth(), dayOfMonth, 1, getDaysInYearMonth(year, monthOfYear)); return getYearMonthDayMillis(year, monthOfYear, dayOfMonth); }