Java Code Examples for org.joda.time.field.FieldUtils#verifyValueBounds()
The following examples show how to use
org.joda.time.field.FieldUtils#verifyValueBounds() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: 1_BasicChronology.java From SimFix with GNU General Public License v2.0 | 6 votes |
public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); } FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23); FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999); return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + hourOfDay * DateTimeConstants.MILLIS_PER_HOUR + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND + millisOfSecond; }
Example 2
Source File: BasicMonthOfYearDateTimeField.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example 3
Source File: BasicChronology.java From astor with GNU General Public License v2.0 | 6 votes |
public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); } FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23); FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999); return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + hourOfDay * DateTimeConstants.MILLIS_PER_HOUR + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND + millisOfSecond; }
Example 4
Source File: patch1-Time-14-Nopol2017_patch1-Time-14-Nopol2017_s.java From coming with MIT License | 6 votes |
/** * 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); }
Example 5
Source File: patch1-Time-14-Nopol2017_patch1-Time-14-Nopol2017_t.java From coming with MIT License | 6 votes |
/** * 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); }
Example 6
Source File: Nopol2017_0086_t.java From coming with MIT License | 6 votes |
/** * 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); }
Example 7
Source File: BasicMonthOfYearDateTimeField.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example 8
Source File: Nopol2017_0088_s.java From coming with MIT License | 6 votes |
public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, int millisOfSecond) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond); } FieldUtils.verifyValueBounds(DateTimeFieldType.hourOfDay(), hourOfDay, 0, 23); FieldUtils.verifyValueBounds(DateTimeFieldType.minuteOfHour(), minuteOfHour, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.secondOfMinute(), secondOfMinute, 0, 59); FieldUtils.verifyValueBounds(DateTimeFieldType.millisOfSecond(), millisOfSecond, 0, 999); return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + hourOfDay * DateTimeConstants.MILLIS_PER_HOUR + minuteOfHour * DateTimeConstants.MILLIS_PER_MINUTE + secondOfMinute * DateTimeConstants.MILLIS_PER_SECOND + millisOfSecond; }
Example 9
Source File: Nopol2017_0088_t.java From coming with MIT License | 5 votes |
public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int millisOfDay) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay); } FieldUtils.verifyValueBounds (DateTimeFieldType.millisOfDay(), millisOfDay, 0, DateTimeConstants.MILLIS_PER_DAY); return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + millisOfDay; }
Example 10
Source File: ISOYearOfEraDateTimeField.java From astor with GNU General Public License v2.0 | 5 votes |
public long set(long instant, int year) { FieldUtils.verifyValueBounds(this, year, 0, getMaximumValue()); if (getWrappedField().get(instant) < 0) { year = -year; } return super.set(instant, year); }
Example 11
Source File: Nopol2017_0088_s.java From coming with MIT License | 5 votes |
public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int millisOfDay) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay); } FieldUtils.verifyValueBounds (DateTimeFieldType.millisOfDay(), millisOfDay, 0, DateTimeConstants.MILLIS_PER_DAY); return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + millisOfDay; }
Example 12
Source File: BasicChronology.java From astor with GNU General Public License v2.0 | 5 votes |
public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int millisOfDay) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay); } FieldUtils.verifyValueBounds (DateTimeFieldType.millisOfDay(), millisOfDay, 0, DateTimeConstants.MILLIS_PER_DAY - 1); return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + millisOfDay; }
Example 13
Source File: 1_BasicChronology.java From SimFix with GNU General Public License v2.0 | 5 votes |
public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int millisOfDay) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay); } FieldUtils.verifyValueBounds (DateTimeFieldType.millisOfDay(), millisOfDay, 0, DateTimeConstants.MILLIS_PER_DAY); return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + millisOfDay; }
Example 14
Source File: BasicChronology.java From astor with GNU General Public License v2.0 | 5 votes |
public long getDateTimeMillis( int year, int monthOfYear, int dayOfMonth, int millisOfDay) throws IllegalArgumentException { Chronology base; if ((base = getBase()) != null) { return base.getDateTimeMillis(year, monthOfYear, dayOfMonth, millisOfDay); } FieldUtils.verifyValueBounds (DateTimeFieldType.millisOfDay(), millisOfDay, 0, DateTimeConstants.MILLIS_PER_DAY - 1); return getDateMidnightMillis(year, monthOfYear, dayOfMonth) + millisOfDay; }
Example 15
Source File: GJEraDateTimeField.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Set the Era component of the specified time instant. * * @param instant the time instant in millis to update. * @param era the era to update the time to. * @return the updated time instant. * @throws IllegalArgumentException if era is invalid. */ public long set(long instant, int era) { FieldUtils.verifyValueBounds(this, era, DateTimeConstants.BCE, DateTimeConstants.CE); int oldEra = get(instant); if (oldEra != era) { int year = iChronology.getYear(instant); return iChronology.setYear(instant, -year); } else { return instant; } }
Example 16
Source File: BasicYearDateTimeField.java From astor with GNU General Public License v2.0 | 4 votes |
public long set(long instant, int year) { FieldUtils.verifyValueBounds (this, year, iChronology.getMinYear(), iChronology.getMaxYear()); return iChronology.setYear(instant, year); }
Example 17
Source File: BasicYearDateTimeField.java From astor with GNU General Public License v2.0 | 4 votes |
public long set(long instant, int year) { FieldUtils.verifyValueBounds (this, year, iChronology.getMinYear(), iChronology.getMaxYear()); return iChronology.setYear(instant, year); }
Example 18
Source File: BasicSingleEraDateTimeField.java From astor with GNU General Public License v2.0 | 4 votes |
/** @inheritDoc */ public long set(long instant, int era) { FieldUtils.verifyValueBounds(this, era, ERA_VALUE, ERA_VALUE); return instant; }
Example 19
Source File: GJYearOfEraDateTimeField.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Set the year component of the specified time instant. * * @param instant the time instant in millis to update. * @param year the year (0,292278994) to update the time to. * @return the updated time instant. * @throws IllegalArgumentException if year is invalid. */ public long set(long instant, int year) { FieldUtils.verifyValueBounds(this, year, 1, getMaximumValue()); if (iChronology.getYear(instant) <= 0) { year = 1 - year; } return super.set(instant, year); }
Example 20
Source File: GJYearOfEraDateTimeField.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Set the year component of the specified time instant. * * @param instant the time instant in millis to update. * @param year the year (0,292278994) to update the time to. * @return the updated time instant. * @throws IllegalArgumentException if year is invalid. */ public long set(long instant, int year) { FieldUtils.verifyValueBounds(this, year, 1, getMaximumValue()); if (iChronology.getYear(instant) <= 0) { year = 1 - year; } return super.set(instant, year); }