当前位置: 首页>>代码示例>>Java>>正文


Java DateTimeField类代码示例

本文整理汇总了Java中org.joda.time.DateTimeField的典型用法代码示例。如果您正苦于以下问题:Java DateTimeField类的具体用法?Java DateTimeField怎么用?Java DateTimeField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DateTimeField类属于org.joda.time包,在下文中一共展示了DateTimeField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RemainderDateTimeField

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param field  the field to wrap, like "year()".
 * @param type  the field type this field actually uses
 * @param divisor  divisor, such as 100 years in a century
 * @throws IllegalArgumentException if divisor is less than two
 */
public RemainderDateTimeField(DateTimeField field,
                              DateTimeFieldType type, int divisor) {
    super(field, type);

    if (divisor < 2) {
        throw new IllegalArgumentException("The divisor must be at least 2");
    }

    DurationField rangeField = field.getDurationField();
    if (rangeField == null) {
        iRangeField = null;
    } else {
        iRangeField = new ScaledDurationField(
            rangeField, type.getRangeDurationType(), divisor);
    }

    iDivisor = divisor;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:27,代码来源:RemainderDateTimeField.java

示例2: DividedDateTimeField

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * Construct a DividedDateTimeField that compliments the given
 * RemainderDateTimeField.
 *
 * @param remainderField  complimentary remainder field, like "yearOfCentury()".
 * @param type  the field type this field will actually use
 */
public DividedDateTimeField(RemainderDateTimeField remainderField, DateTimeFieldType type) {
    super(remainderField.getWrappedField(), type);
    int divisor = iDivisor = remainderField.iDivisor;
    iDurationField = remainderField.iRangeField;

    DateTimeField field = getWrappedField();
    int i = field.getMinimumValue();
    int min = (i >= 0) ? i / divisor : ((i + 1) / divisor - 1);

    int j = field.getMaximumValue();
    int max = (j >= 0) ? j / divisor : ((j + 1) / divisor - 1);

    iMin = min;
    iMax = max;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:23,代码来源:DividedDateTimeField.java

示例3: getTimestampField

import org.joda.time.DateTimeField; //导入依赖的package包/类
private static DateTimeField getTimestampField(ISOChronology chronology, Slice unit)
{
    String unitString = unit.toStringUtf8().toLowerCase(ENGLISH);
    switch (unitString) {
        case "millisecond":
            return chronology.millisOfSecond();
        case "second":
            return chronology.secondOfMinute();
        case "minute":
            return chronology.minuteOfHour();
        case "hour":
            return chronology.hourOfDay();
        case "day":
            return chronology.dayOfMonth();
        case "week":
            return chronology.weekOfWeekyear();
        case "month":
            return chronology.monthOfYear();
        case "quarter":
            return QUARTER_OF_YEAR.getField(chronology);
        case "year":
            return chronology.year();
    }
    throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "'" + unitString + "' is not a valid Timestamp field");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:DateTimeFunctions.java

示例4: ZonedDateTimeField

import org.joda.time.DateTimeField; //导入依赖的package包/类
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;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:17,代码来源:ZonedChronology.java

示例5: CutoverField

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:24,代码来源:GJChronology.java

示例6: getDateField

import org.joda.time.DateTimeField; //导入依赖的package包/类
private static DateTimeField getDateField(ISOChronology chronology, Slice unit)
{
    String unitString = unit.toStringUtf8().toLowerCase(ENGLISH);
    switch (unitString) {
        case "day":
            return chronology.dayOfMonth();
        case "week":
            return chronology.weekOfWeekyear();
        case "month":
            return chronology.monthOfYear();
        case "quarter":
            return QUARTER_OF_YEAR.getField(chronology);
        case "year":
            return chronology.year();
    }
    throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "'" + unitString + "' is not a valid DATE field");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:DateTimeFunctions.java

示例7: getFields

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * Gets an array of the fields that this partial supports.
 * <p>
 * The fields are returned largest to smallest, for example Hour, Minute, Second.
 *
 * @return the fields supported in an array that may be altered, largest to smallest
 */
public DateTimeField[] getFields() {
    DateTimeField[] result = new DateTimeField[size()];
    for (int i = 0; i < result.length; i++) {
        result[i] = getField(i);
    }
    return result;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:15,代码来源:AbstractPartial.java

示例8: getInstance

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * Returns a lenient version of the given field. If it is already lenient,
 * then it is returned as-is. Otherwise, a new LenientDateTimeField is
 * returned.
 */
public static DateTimeField getInstance(DateTimeField field, Chronology base) {
    if (field == null) {
        return null;
    }
    if (field instanceof StrictDateTimeField) {
        field = ((StrictDateTimeField)field).getWrappedField();
    }
    if (field.isLenient()) {
        return field;
    }
    return new LenientDateTimeField(field, base);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:18,代码来源:LenientDateTimeField.java

示例9: getTimeField

import org.joda.time.DateTimeField; //导入依赖的package包/类
private static DateTimeField getTimeField(ISOChronology chronology, Slice unit)
{
    String unitString = unit.toStringUtf8().toLowerCase(ENGLISH);
    switch (unitString) {
        case "millisecond":
            return chronology.millisOfSecond();
        case "second":
            return chronology.secondOfMinute();
        case "minute":
            return chronology.minuteOfHour();
        case "hour":
            return chronology.hourOfDay();
    }
    throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "'" + unitString + "' is not a valid Time field");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:16,代码来源:DateTimeFunctions.java

示例10: SkipUndoDateTimeField

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param chronology  the chronoogy to use
 * @param field  the field to skip zero on
 * @param skip  the value to skip
 */
public SkipUndoDateTimeField(Chronology chronology, DateTimeField field, int skip) {
    super(field);
    iChronology = chronology;
    int min = super.getMinimumValue();
    if (min < skip) {
        iMinValue = min + 1;
    } else if (min == skip + 1) {
        iMinValue = skip;
    } else {
        iMinValue = min;
    }
    iSkip = skip;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:21,代码来源:SkipUndoDateTimeField.java

示例11: DelegatedDateTimeField

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:15,代码来源:DelegatedDateTimeField.java

示例12: verifyValueBounds

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * 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));
    }
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:17,代码来源:FieldUtils.java

示例13: SkipDateTimeField

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param chronology  the chronoogy to use
 * @param field  the field to skip zero on
 * @param skip  the value to skip
 */
public SkipDateTimeField(Chronology chronology, DateTimeField field, int skip) {
    super(field);
    iChronology = chronology;
    int min = super.getMinimumValue();
    if (min < skip) {
        iMinValue = min - 1;
    } else if (min == skip) {
        iMinValue = skip + 1;
    } else {
        iMinValue = min;
    }
    iSkip = skip;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:21,代码来源:SkipDateTimeField.java

示例14: getInstance

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * Returns a strict version of the given field. If it is already strict,
 * then it is returned as-is. Otherwise, a new StrictDateTimeField is
 * returned.
 */
public static DateTimeField getInstance(DateTimeField field) {
    if (field == null) {
        return null;
    }
    if (field instanceof LenientDateTimeField) {
        field = ((LenientDateTimeField)field).getWrappedField();
    }
    if (!field.isLenient()) {
        return field;
    }
    return new StrictDateTimeField(field);
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:18,代码来源:StrictDateTimeField.java

示例15: DecoratedDateTimeField

import org.joda.time.DateTimeField; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param field  the field being decorated
 * @param type  allow type to be overridden
 */
protected DecoratedDateTimeField(DateTimeField field, DateTimeFieldType type) {
    super(type);
    if (field == null) {
        throw new IllegalArgumentException("The field must not be null");
    }
    if (!field.isSupported()) {
        throw new IllegalArgumentException("The field must be supported");
    }
    iField = field;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:17,代码来源:DecoratedDateTimeField.java


注:本文中的org.joda.time.DateTimeField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。