Java 类org.joda.time.DateTimeField 实例源码

项目:TinyTravelTracker    文件:RemainderDateTimeField.java   
/**
 * 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;
}
项目:TinyTravelTracker    文件:DividedDateTimeField.java   
/**
 * 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;
}
项目:presto    文件:DateTimeFunctions.java   
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");
}
项目:TinyTravelTracker    文件:ZonedChronology.java   
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;
}
项目:TinyTravelTracker    文件:GJChronology.java   
/**
 * @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;
}
项目:presto    文件:DateTimeFunctions.java   
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");
}
项目:TinyTravelTracker    文件:AbstractPartial.java   
/**
 * 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;
}
项目:TinyTravelTracker    文件:LenientDateTimeField.java   
/**
 * 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);
}
项目:TinyTravelTracker    文件:DividedDateTimeField.java   
/**
 * Constructor.
 * 
 * @param field  the field to wrap, like "year()".
 * @param type  the field type this field will actually use
 * @param divisor  divisor, such as 100 years in a century
 * @throws IllegalArgumentException if divisor is less than two
 */
public DividedDateTimeField(DateTimeField field,
                            DateTimeFieldType type, int divisor) {
    super(field, type);

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

    DurationField unitField = field.getDurationField();
    if (unitField == null) {
        iDurationField = null;
    } else {
        iDurationField = new ScaledDurationField(
            unitField, type.getDurationType(), divisor);
    }

    iDivisor = divisor;

    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;
}
项目:presto    文件:DateTimeFunctions.java   
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");
}
项目:TinyTravelTracker    文件:SkipUndoDateTimeField.java   
/**
 * 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;
}
项目:TinyTravelTracker    文件:DelegatedDateTimeField.java   
/**
 * 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);
}
项目:TinyTravelTracker    文件:FieldUtils.java   
/**
 * 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));
    }
}
项目:TinyTravelTracker    文件:SkipDateTimeField.java   
/**
 * 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;
}
项目:TinyTravelTracker    文件:StrictDateTimeField.java   
/**
 * 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);
}
项目:TinyTravelTracker    文件:DecoratedDateTimeField.java   
/**
 * 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;
}
项目:TinyTravelTracker    文件:DateTimeFormatterBuilder.java   
public void printTo(
        StringBuffer buf, long instant, Chronology chrono,
        int displayOffset, DateTimeZone displayZone, Locale locale) {
    try {
        DateTimeField field = iFieldType.getField(chrono);
        FormatUtils.appendUnpaddedInteger(buf, field.get(instant));
    } catch (RuntimeException e) {
        buf.append('\ufffd');
    }
}
项目:TinyTravelTracker    文件:DateTimeFormatterBuilder.java   
public void printTo(
        Writer out, long instant, Chronology chrono,
        int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException {
    try {
        DateTimeField field = iFieldType.getField(chrono);
        FormatUtils.writeUnpaddedInteger(out, field.get(instant));
    } catch (RuntimeException e) {
        out.write('\ufffd');
    }
}
项目:TinyTravelTracker    文件:DateTimeFormatterBuilder.java   
public void printTo(
        StringBuffer buf, long instant, Chronology chrono,
        int displayOffset, DateTimeZone displayZone, Locale locale) {
    try {
        DateTimeField field = iFieldType.getField(chrono);
        FormatUtils.appendPaddedInteger(buf, field.get(instant), iMinPrintedDigits);
    } catch (RuntimeException e) {
        appendUnknownString(buf, iMinPrintedDigits);
    }
}
项目:TinyTravelTracker    文件:DateTimeFormatterBuilder.java   
public void printTo(
        Writer out, long instant, Chronology chrono,
        int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException {
    try {
        DateTimeField field = iFieldType.getField(chrono);
        FormatUtils.writePaddedInteger(out, field.get(instant), iMinPrintedDigits);
    } catch (RuntimeException e) {
        printUnknownString(out, iMinPrintedDigits);
    }
}
项目:TinyTravelTracker    文件:DateTimeFormatterBuilder.java   
private String print(long instant, Chronology chrono, Locale locale) {
    DateTimeField field = iFieldType.getField(chrono);
    if (iShort) {
        return field.getAsShortText(instant, locale);
    } else {
        return field.getAsText(instant, locale);
    }
}
项目:TinyTravelTracker    文件:DateTimeFormatterBuilder.java   
private String print(ReadablePartial partial, Locale locale) {
    if (partial.isSupported(iFieldType)) {
        DateTimeField field = iFieldType.getField(partial.getChronology());
        if (iShort) {
            return field.getAsShortText(partial, locale);
        } else {
            return field.getAsText(partial, locale);
        }
    } else {
        return "\ufffd";
    }
}
项目:TinyTravelTracker    文件:DateTimeFormatterBuilder.java   
private long[] getFractionData(long fraction, DateTimeField field) {
    long rangeMillis = field.getDurationField().getUnitMillis();
    long scalar;
    int maxDigits = iMaxDigits;
    while (true) {
        switch (maxDigits) {
        default: scalar = 1L; break;
        case 1:  scalar = 10L; break;
        case 2:  scalar = 100L; break;
        case 3:  scalar = 1000L; break;
        case 4:  scalar = 10000L; break;
        case 5:  scalar = 100000L; break;
        case 6:  scalar = 1000000L; break;
        case 7:  scalar = 10000000L; break;
        case 8:  scalar = 100000000L; break;
        case 9:  scalar = 1000000000L; break;
        case 10: scalar = 10000000000L; break;
        case 11: scalar = 100000000000L; break;
        case 12: scalar = 1000000000000L; break;
        case 13: scalar = 10000000000000L; break;
        case 14: scalar = 100000000000000L; break;
        case 15: scalar = 1000000000000000L; break;
        case 16: scalar = 10000000000000000L; break;
        case 17: scalar = 100000000000000000L; break;
        case 18: scalar = 1000000000000000000L; break;
        }
        if (((rangeMillis * scalar) / scalar) == rangeMillis) {
            break;
        }
        // Overflowed: scale down.
        maxDigits--;
    }

    return new long[] {fraction * scalar / rangeMillis, maxDigits};
}
项目:TinyTravelTracker    文件:DateTimeParserBucket.java   
/**
 * The field with the longer range duration is ordered first, where
 * null is considered infinite. If the ranges match, then the field
 * with the longer duration is ordered first.
 */
public int compareTo(SavedField obj) {
    DateTimeField other = obj.iField;
    int result = compareReverse
        (iField.getRangeDurationField(), other.getRangeDurationField());
    if (result != 0) {
        return result;
    }
    return compareReverse
        (iField.getDurationField(), other.getDurationField());
}
项目:TinyTravelTracker    文件:LimitChronology.java   
private DateTimeField convertField(DateTimeField field, HashMap<Object, Object> converted) {
    if (field == null || !field.isSupported()) {
        return field;
    }
    if (converted.containsKey(field)) {
        return (DateTimeField)converted.get(field);
    }
    LimitDateTimeField limitField =
        new LimitDateTimeField(field,
                               convertField(field.getDurationField(), converted),
                               convertField(field.getRangeDurationField(), converted),
                               convertField(field.getLeapDurationField(), converted));
    converted.put(field, limitField);
    return limitField;
}
项目:TinyTravelTracker    文件:ZonedChronology.java   
private DateTimeField convertField(DateTimeField field, HashMap<Object, Object> converted) {
    if (field == null || !field.isSupported()) {
        return field;
    }
    if (converted.containsKey(field)) {
        return (DateTimeField)converted.get(field);
    }
    ZonedDateTimeField zonedField =
        new ZonedDateTimeField(field, getZone(),
                               convertField(field.getDurationField(), converted),
                               convertField(field.getRangeDurationField(), converted),
                               convertField(field.getLeapDurationField(), converted));
    converted.put(field, zonedField);
    return zonedField;
}
项目:TinyTravelTracker    文件:GJChronology.java   
public int getMaximumValue(ReadablePartial partial, int[] values) {
    Chronology chrono = GJChronology.getInstanceUTC();
    long instant = 0L;
    for (int i = 0, isize = partial.size(); i < isize; i++) {
        DateTimeField field = partial.getFieldType(i).getField(chrono);
        if (values[i] <= field.getMaximumValue(instant)) {
            instant = field.set(instant, values[i]);
        }
    }
    return getMaximumValue(instant);
}
项目:TinyTravelTracker    文件:GJChronology.java   
/**
 * Uses a shared duration field rather than creating a new one.
 *
 * @param durationField shared duration field
 */
ImpreciseCutoverField(DateTimeField julianField, DateTimeField gregorianField,
                      DurationField durationField,
                      long cutoverMillis, boolean convertByWeekyear)
{
    super(julianField, gregorianField, cutoverMillis, convertByWeekyear);
    if (durationField == null) {
        durationField = new LinkedDurationField(iDurationField, this);
    }
    iDurationField = durationField;
}
项目:elasticsearch_my    文件:Joda.java   
@Override
public DateTimeField getField(Chronology chronology) {
    return new OffsetDateTimeField(new DividedDateTimeField(new OffsetDateTimeField(chronology.monthOfYear(), -1), QuarterOfYear, 3), 1);
}
项目:LAS    文件:FixedYearVariableMonthChronology.java   
@Override
public final DateTimeField dayOfMonth() {
    return this.dayOfMonth;
}
项目:LAS    文件:FixedYearVariableMonthChronology.java   
@Override
public final DateTimeField monthOfYear() {
    return this.monthOfYear;
}
项目:LAS    文件:FixedYearLengthChronology.java   
@Override
public final DateTimeField millisOfSecond() { return millisOfSecond; }
项目:LAS    文件:FixedYearLengthChronology.java   
@Override
public final DateTimeField millisOfDay() { return millisOfDay; }
项目:LAS    文件:FixedYearLengthChronology.java   
@Override
public final DateTimeField secondOfMinute() { return secondOfMinute; }
项目:LAS    文件:FixedYearLengthChronology.java   
@Override
public final DateTimeField secondOfDay() { return secondOfDay; }
项目:LAS    文件:FixedYearLengthChronology.java   
@Override
public final DateTimeField minuteOfHour() { return minuteOfHour; }
项目:LAS    文件:FixedYearLengthChronology.java   
@Override
public final DateTimeField minuteOfDay() { return minuteOfDay; }
项目:LAS    文件:FixedYearLengthChronology.java   
@Override
public final DateTimeField hourOfDay() { return hourOfDay; }
项目:LAS    文件:FixedYearLengthChronology.java   
@Override
public final DateTimeField hourOfHalfday() { return hourOfHalfday; }
项目:LAS    文件:FixedYearLengthChronology.java   
@Override
public final DateTimeField halfdayOfDay() { return halfdayOfDay; }