Java 类org.joda.time.format.DateTimeParserBucket 实例源码

项目:heroic    文件:Tasks.java   
private static long parseTodayInstant(String input, final Chronology chrono, long now) {
    final DateTime n = new DateTime(now, chrono);

    for (final DateTimeParser p : today) {
        final DateTimeParserBucket bucket =
            new DateTimeParserBucket(0, chrono, null, null, 2000);

        bucket.saveField(chrono.year(), n.getYear());
        bucket.saveField(chrono.monthOfYear(), n.getMonthOfYear());
        bucket.saveField(chrono.dayOfYear(), n.getDayOfYear());

        try {
            p.parseInto(bucket, input, 0);
        } catch (IllegalArgumentException e) {
            // pass-through
            continue;
        }

        return bucket.computeMillis();
    }

    throw new IllegalArgumentException(input + " is not a valid instant");
}
项目:heroic    文件:Tasks.java   
private static long parseFullInstant(String input, final Chronology chrono) {
    for (final DateTimeParser p : full) {
        final DateTimeParserBucket bucket =
            new DateTimeParserBucket(0, chrono, null, null, 2000);

        try {
            p.parseInto(bucket, input, 0);
        } catch (IllegalArgumentException e) {
            // pass-through
            continue;
        }

        return bucket.computeMillis();
    }

    throw new IllegalArgumentException(input + " is not a valid instant");
}
项目:elasticsearch_my    文件:Joda.java   
@Override
public int parseInto(DateTimeParserBucket bucket, String text, int position) {
    boolean isPositive = text.startsWith("-") == false;
    boolean isTooLong = text.length() > estimateParsedLength();

    if ((isPositive && isTooLong) ||
        // timestamps have to have UTC timezone
        bucket.getZone() != DateTimeZone.UTC) {
        return -1;
    }

    int factor = hasMilliSecondPrecision ? 1 : 1000;
    try {
        long millis = Long.valueOf(text) * factor;
        DateTime dt = new DateTime(millis, DateTimeZone.UTC);
        bucket.saveField(DateTimeFieldType.year(), dt.getYear());
        bucket.saveField(DateTimeFieldType.monthOfYear(), dt.getMonthOfYear());
        bucket.saveField(DateTimeFieldType.dayOfMonth(), dt.getDayOfMonth());
        bucket.saveField(DateTimeFieldType.hourOfDay(), dt.getHourOfDay());
        bucket.saveField(DateTimeFieldType.minuteOfHour(), dt.getMinuteOfHour());
        bucket.saveField(DateTimeFieldType.secondOfMinute(), dt.getSecondOfMinute());
        bucket.saveField(DateTimeFieldType.millisOfSecond(), dt.getMillisOfSecond());
        bucket.setZone(DateTimeZone.UTC);
    } catch (Exception e) {
        return -1;
    }
    return text.length();
}
项目:eHMP    文件:TwoDigitNumber.java   
public int parseInto(DateTimeParserBucket bucket, String text, int position) {
    int value = ParseUtils.parseTwoDigits(text, position);
    if (value > 0 || (value == 0 && (type == DateTimeFieldType.hourOfDay() || type == DateTimeFieldType
            .minuteOfHour() || type == DateTimeFieldType.secondOfMinute() || type == DateTimeFieldType
            .millisOfSecond())))
        bucket.saveField(type, value);
    return position + 2 > text.length() ? position + 1 : position + 2;
}
项目:eHMP    文件:TwoDigitNumber.java   
public int parseInto(DateTimeParserBucket bucket, String text, int position) {
    int value = parseTwoDigits(text, position);
    if (value > 0 || (value == 0 && (type == DateTimeFieldType.hourOfDay() || type == DateTimeFieldType
            .minuteOfHour() || type == DateTimeFieldType.secondOfMinute() || type == DateTimeFieldType
            .millisOfSecond())))
        bucket.saveField(type, value);
    return position + 2 > text.length() ? position + 1 : position + 2;
}
项目:eHMP    文件:ParseUtils.java   
public int parseInto(DateTimeParserBucket bucket, String text, int position) {
    return position + 1;
}