本文整理汇总了Java中org.joda.time.field.FieldUtils.verifyValueBounds方法的典型用法代码示例。如果您正苦于以下问题:Java FieldUtils.verifyValueBounds方法的具体用法?Java FieldUtils.verifyValueBounds怎么用?Java FieldUtils.verifyValueBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.field.FieldUtils
的用法示例。
在下文中一共展示了FieldUtils.verifyValueBounds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDateTimeMillis
import org.joda.time.field.FieldUtils; //导入方法依赖的package包/类
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;
}
示例2: set
import org.joda.time.field.FieldUtils; //导入方法依赖的package包/类
/**
* 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);
}
示例3: set
import org.joda.time.field.FieldUtils; //导入方法依赖的package包/类
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);
}
示例4: set
import org.joda.time.field.FieldUtils; //导入方法依赖的package包/类
/**
* 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;
}
}
示例5: set
import org.joda.time.field.FieldUtils; //导入方法依赖的package包/类
/** @inheritDoc */
public long set(long instant, int era) {
FieldUtils.verifyValueBounds(this, era, ERA_VALUE, ERA_VALUE);
return instant;
}
示例6: set
import org.joda.time.field.FieldUtils; //导入方法依赖的package包/类
public long set(long instant, int year) {
FieldUtils.verifyValueBounds
(this, year, iChronology.getMinYear(), iChronology.getMaxYear());
return iChronology.setYear(instant, year);
}
示例7: getDateMidnightMillis
import org.joda.time.field.FieldUtils; //导入方法依赖的package包/类
/**
* 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);
}
示例8: set
import org.joda.time.field.FieldUtils; //导入方法依赖的package包/类
/**
* 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);
}