下面列出了org.joda.time.DateTimeField#getType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* @param julianField field from the chronology used before the cutover instant
* @param gregorianField field from the chronology used at and after the cutover
* @param cutoverMillis the millis of the cutover
* @param convertByWeekyear
*/
CutoverField(DateTimeField julianField, DateTimeField gregorianField,
long cutoverMillis, boolean convertByWeekyear) {
super(gregorianField.getType());
iJulianField = julianField;
iGregorianField = gregorianField;
iCutover = cutoverMillis;
iConvertByWeekyear = convertByWeekyear;
// Although average length of Julian and Gregorian years differ,
// use the Gregorian duration field because it is more accurate.
iDurationField = gregorianField.getDurationField();
DurationField rangeField = gregorianField.getRangeDurationField();
if (rangeField == null) {
rangeField = julianField.getRangeDurationField();
}
iRangeDurationField = rangeField;
}
/**
* @param julianField field from the chronology used before the cutover instant
* @param gregorianField field from the chronology used at and after the cutover
* @param cutoverMillis the millis of the cutover
* @param convertByWeekyear
*/
CutoverField(DateTimeField julianField, DateTimeField gregorianField,
long cutoverMillis, boolean convertByWeekyear) {
super(gregorianField.getType());
iJulianField = julianField;
iGregorianField = gregorianField;
iCutover = cutoverMillis;
iConvertByWeekyear = convertByWeekyear;
// Although average length of Julian and Gregorian years differ,
// use the Gregorian duration field because it is more accurate.
iDurationField = gregorianField.getDurationField();
DurationField rangeField = gregorianField.getRangeDurationField();
if (rangeField == null) {
rangeField = julianField.getRangeDurationField();
}
iRangeDurationField = rangeField;
}
/**
* @param julianField field from the chronology used before the cutover instant
* @param gregorianField field from the chronology used at and after the cutover
* @param cutoverMillis the millis of the cutover
* @param convertByWeekyear
*/
CutoverField(DateTimeField julianField, DateTimeField gregorianField,
long cutoverMillis, boolean convertByWeekyear) {
super(gregorianField.getType());
iJulianField = julianField;
iGregorianField = gregorianField;
iCutover = cutoverMillis;
iConvertByWeekyear = convertByWeekyear;
// Although average length of Julian and Gregorian years differ,
// use the Gregorian duration field because it is more accurate.
iDurationField = gregorianField.getDurationField();
DurationField rangeField = gregorianField.getRangeDurationField();
if (rangeField == null) {
rangeField = julianField.getRangeDurationField();
}
iRangeDurationField = rangeField;
}
/**
* @param julianField field from the chronology used before the cutover instant
* @param gregorianField field from the chronology used at and after the cutover
* @param cutoverMillis the millis of the cutover
* @param convertByWeekyear
*/
CutoverField(DateTimeField julianField, DateTimeField gregorianField,
long cutoverMillis, boolean convertByWeekyear) {
super(gregorianField.getType());
iJulianField = julianField;
iGregorianField = gregorianField;
iCutover = cutoverMillis;
iConvertByWeekyear = convertByWeekyear;
// Although average length of Julian and Gregorian years differ,
// use the Gregorian duration field because it is more accurate.
iDurationField = gregorianField.getDurationField();
DurationField rangeField = gregorianField.getRangeDurationField();
if (rangeField == null) {
rangeField = julianField.getRangeDurationField();
}
iRangeDurationField = rangeField;
}
ZonedDateTimeField(DateTimeField field,
DateTimeZone zone,
DurationField durationField,
DurationField rangeDurationField,
DurationField leapDurationField) {
super(field.getType());
if (!field.isSupported()) {
throw new IllegalArgumentException();
}
iField = field;
iZone = zone;
iDurationField = durationField;
iTimeField = useTimeArithmetic(durationField);
iRangeDurationField = rangeDurationField;
iLeapDurationField = leapDurationField;
}
ZonedDateTimeField(DateTimeField field,
DateTimeZone zone,
DurationField durationField,
DurationField rangeDurationField,
DurationField leapDurationField) {
super(field.getType());
if (!field.isSupported()) {
throw new IllegalArgumentException();
}
iField = field;
iZone = zone;
iDurationField = durationField;
iTimeField = useTimeArithmetic(durationField);
iRangeDurationField = rangeDurationField;
iLeapDurationField = leapDurationField;
}
/**
* @param julianField field from the chronology used before the cutover instant
* @param gregorianField field from the chronology used at and after the cutover
* @param rangeField the range field
* @param cutoverMillis the millis of the cutover
* @param convertByWeekyear
*/
CutoverField(DateTimeField julianField, DateTimeField gregorianField,
DurationField rangeField, long cutoverMillis, boolean convertByWeekyear) {
super(gregorianField.getType());
iJulianField = julianField;
iGregorianField = gregorianField;
iCutover = cutoverMillis;
iConvertByWeekyear = convertByWeekyear;
// Although average length of Julian and Gregorian years differ,
// use the Gregorian duration field because it is more accurate.
iDurationField = gregorianField.getDurationField();
if (rangeField == null) {
rangeField = gregorianField.getRangeDurationField();
if (rangeField == null) {
rangeField = julianField.getRangeDurationField();
}
}
iRangeDurationField = rangeField;
}
/**
* Verify that input values are within specified bounds.
*
* @param value the value to check
* @param lowerBound the lower bound allowed for value
* @param upperBound the upper bound allowed for value
* @throws IllegalFieldValueException if value is not in the specified bounds
*/
public static void verifyValueBounds(DateTimeField field,
int value, int lowerBound, int upperBound) {
if ((value < lowerBound) || (value > upperBound)) {
throw new IllegalFieldValueException
(field.getType(), Integer.valueOf(value),
Integer.valueOf(lowerBound), Integer.valueOf(upperBound));
}
}
/**
* Verify that input values are within specified bounds.
*
* @param value the value to check
* @param lowerBound the lower bound allowed for value
* @param upperBound the upper bound allowed for value
* @throws IllegalFieldValueException if value is not in the specified bounds
*/
public static void verifyValueBounds(DateTimeField field,
int value, int lowerBound, int upperBound) {
if ((value < lowerBound) || (value > upperBound)) {
throw new IllegalFieldValueException
(field.getType(), Integer.valueOf(value),
Integer.valueOf(lowerBound), Integer.valueOf(upperBound));
}
}
/**
* Verify that input values are within specified bounds.
*
* @param value the value to check
* @param lowerBound the lower bound allowed for value
* @param upperBound the upper bound allowed for value
* @throws IllegalFieldValueException if value is not in the specified bounds
*/
public static void verifyValueBounds(DateTimeField field,
int value, int lowerBound, int upperBound) {
if ((value < lowerBound) || (value > upperBound)) {
throw new IllegalFieldValueException
(field.getType(), Integer.valueOf(value),
Integer.valueOf(lowerBound), Integer.valueOf(upperBound));
}
}
/**
* Verify that input values are within specified bounds.
*
* @param value the value to check
* @param lowerBound the lower bound allowed for value
* @param upperBound the upper bound allowed for value
* @throws IllegalFieldValueException if value is not in the specified bounds
*/
public static void verifyValueBounds(DateTimeField field,
int value, int lowerBound, int upperBound) {
if ((value < lowerBound) || (value > upperBound)) {
throw new IllegalFieldValueException
(field.getType(), Integer.valueOf(value),
Integer.valueOf(lowerBound), Integer.valueOf(upperBound));
}
}
/**
* Verify that input values are within specified bounds.
*
* @param value the value to check
* @param lowerBound the lower bound allowed for value
* @param upperBound the upper bound allowed for value
* @throws IllegalFieldValueException if value is not in the specified bounds
*/
public static void verifyValueBounds(DateTimeField field,
int value, int lowerBound, int upperBound) {
if ((value < lowerBound) || (value > upperBound)) {
throw new IllegalFieldValueException
(field.getType(), Integer.valueOf(value),
Integer.valueOf(lowerBound), Integer.valueOf(upperBound));
}
}
/**
* Verify that input values are within specified bounds.
*
* @param value the value to check
* @param lowerBound the lower bound allowed for value
* @param upperBound the upper bound allowed for value
* @throws IllegalFieldValueException if value is not in the specified bounds
*/
public static void verifyValueBounds(DateTimeField field,
int value, int lowerBound, int upperBound) {
if ((value < lowerBound) || (value > upperBound)) {
throw new IllegalFieldValueException
(field.getType(), Integer.valueOf(value),
Integer.valueOf(lowerBound), Integer.valueOf(upperBound));
}
}
/**
* Constructor.
*
* @param field the field being decorated
* @param type the field type override
*/
public DelegatedDateTimeField(DateTimeField field, DateTimeFieldType type) {
super();
if (field == null) {
throw new IllegalArgumentException("The field must not be null");
}
iField = field;
iType = (type == null ? field.getType() : type);
}
LimitDateTimeField(DateTimeField field,
DurationField durationField,
DurationField rangeDurationField,
DurationField leapDurationField) {
super(field, field.getType());
iDurationField = durationField;
iRangeDurationField = rangeDurationField;
iLeapDurationField = leapDurationField;
}
/**
* Constructor.
*
* @param field the field being decorated
* @param rangeField the range field, null to derive
* @param type the field type override
*/
public DelegatedDateTimeField(DateTimeField field, DurationField rangeField, DateTimeFieldType type) {
super();
if (field == null) {
throw new IllegalArgumentException("The field must not be null");
}
iField = field;
iRangeDurationField = rangeField;
iType = (type == null ? field.getType() : type);
}
/**
* Verify that input values are within specified bounds.
*
* @param value the value to check
* @param lowerBound the lower bound allowed for value
* @param upperBound the upper bound allowed for value
* @throws IllegalFieldValueException if value is not in the specified bounds
*/
public static void verifyValueBounds(DateTimeField field,
int value, int lowerBound, int upperBound) {
if ((value < lowerBound) || (value > upperBound)) {
throw new IllegalFieldValueException
(field.getType(), Integer.valueOf(value),
Integer.valueOf(lowerBound), Integer.valueOf(upperBound));
}
}
LimitDateTimeField(DateTimeField field,
DurationField durationField,
DurationField rangeDurationField,
DurationField leapDurationField) {
super(field, field.getType());
iDurationField = durationField;
iRangeDurationField = rangeDurationField;
iLeapDurationField = leapDurationField;
}
/**
* Constructor.
*
* @param field the field to wrap, like "year()".
* @param offset offset to add to field values
* @throws IllegalArgumentException if offset is zero
*/
public OffsetDateTimeField(DateTimeField field, int offset) {
this(field, (field == null ? null : field.getType()), offset, Integer.MIN_VALUE, Integer.MAX_VALUE);
}
/**
* Constructor.
*
* @param field the field to wrap, like "year()".
* @param offset offset to add to field values
* @throws IllegalArgumentException if offset is zero
*/
public OffsetDateTimeField(DateTimeField field, int offset) {
this(field, (field == null ? null : field.getType()), offset, Integer.MIN_VALUE, Integer.MAX_VALUE);
}