Package org.goda.time

Examples of org.goda.time.DateTimeField


        // check values in standard range, catching really stupid cases like -1
        // this means that the second check will not hit trouble
        int size = partial.size();
        for (int i = 0; i < size; i++) {
            int value = values[i];
            DateTimeField field = partial.getField(i);
            if (value < field.getMinimumValue()) {
                throw new IllegalFieldValueException
                    (field.getType(), new Integer(value),
                     new Integer(field.getMinimumValue()), null);
            }
            if (value > field.getMaximumValue()) {
                throw new IllegalFieldValueException
                    (field.getType(), new Integer(value),
                     null, new Integer(field.getMaximumValue()));
            }
        }
        // check values in specific range, catching really odd cases like 30th Feb
        for (int i = 0; i < size; i++) {
            int value = values[i];
            DateTimeField field = partial.getField(i);
            if (value < field.getMinimumValue(partial, values)) {
                throw new IllegalFieldValueException
                    (field.getType(), new Integer(value),
                     new Integer(field.getMinimumValue(partial, values)), null);
            }
            if (value > field.getMaximumValue(partial, values)) {
                throw new IllegalFieldValueException
                    (field.getType(), new Integer(value),
                     null, new Integer(field.getMaximumValue(partial, values)));
            }
        }
    }
View Full Code Here


        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);
        }
View Full Code Here

         * 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(Object obj) {
            DateTimeField other = ((SavedField)obj).iField;
            int result = compareReverse
                (iField.getRangeDurationField(), other.getRangeDurationField());
            if (result != 0) {
                return result;
            }
            return compareReverse
                (iField.getDurationField(), other.getDurationField());
        }
View Full Code Here

            iCenturies = (f = fields.centuries) != null ? f : super.centuries();
            iEras      = (f = fields.eras)      != null ? f : super.eras();
        }

        {
            DateTimeField f;
            iMillisOfSecond     = (f = fields.millisOfSecond)     != null ? f : super.millisOfSecond();
            iMillisOfDay        = (f = fields.millisOfDay)        != null ? f : super.millisOfDay();
            iSecondOfMinute     = (f = fields.secondOfMinute)     != null ? f : super.secondOfMinute();
            iSecondOfDay        = (f = fields.secondOfDay)        != null ? f : super.secondOfDay();
            iMinuteOfHour       = (f = fields.minuteOfHour)       != null ? f : super.minuteOfHour();
View Full Code Here

                    eras = f;
                }
            }

            {
                DateTimeField f;
                if (isSupported(f = chrono.millisOfSecond())) {
                    millisOfSecond = f;
                }
                if (isSupported(f = chrono.millisOfDay())) {
                    millisOfDay = f;
View Full Code Here

    }

    protected void assemble(Fields fields) {
        if (getParam() == null) {
            // julian chrono removed zero, but we need to put it back
            DateTimeField field = fields.year;
            fields.year = new OffsetDateTimeField(
                    new SkipUndoDateTimeField(this, field), BUDDHIST_OFFSET);
           
            // one era, so yearOfEra is the same
            field = fields.yearOfEra;
View Full Code Here

        fields.year = new BasicYearDateTimeField(this);
        fields.yearOfEra = new GJYearOfEraDateTimeField(fields.year, this);

        // Define one-based centuryOfEra and yearOfCentury.
        DateTimeField field = new OffsetDateTimeField(
            fields.yearOfEra, 99);
        fields.centuryOfEra = new DividedDateTimeField(
            field, DateTimeFieldType.centuryOfEra(), 100);
       
        field = new RemainderDateTimeField(
View Full Code Here

//        }

        protected void printTo(StringBuffer buf, Object out, long instant, Chronology chrono)
           
        {
            DateTimeField field = iFieldType.getField(chrono);
            int minDigits = iMinDigits;

            long fraction;
            try {
                fraction = field.remainder(instant);
            } catch (RuntimeException e) {
                if (buf != null) {
                    appendUnknownString(buf, minDigits);
                }
//                else {
View Full Code Here

        public int estimateParsedLength() {
            return iMaxDigits;
        }

        public int parseInto(DateTimeParserBucket bucket, String text, int position) {
            DateTimeField field = iFieldType.getField(bucket.getChronology());
           
            int limit = Math.min(iMaxDigits, text.length() - position);

            long value = 0;
            long n = field.getDurationField().getUnitMillis() * 10;
            int length = 0;
            while (length < limit) {
                char c = text.charAt(position + length);
                if (c < '0' || c > '9') {
                    break;
                }
                length++;
                long nn = n / 10;
                value += (c - '0') * nn;
                n = nn;
            }

            value /= 10;

            if (length == 0) {
                return ~position;
            }

            if (value > Integer.MAX_VALUE) {
                return ~position;
            }

            DateTimeField parseField = new PreciseDateTimeField(
                DateTimeFieldType.millisOfSecond(),
                MillisDurationField.INSTANCE,
                field.getDurationField());

            bucket.saveField(parseField, (int) value);
View Full Code Here

     * @param index  the index
     * @param value  the value to set
     * @throws IndexOutOfBoundsException if the index is invalid
     */
    protected void setValue(int index, int value) {
        DateTimeField field = getField(index);
        iValues = field.set(this, index, iValues, value);
    }
View Full Code Here

TOP

Related Classes of org.goda.time.DateTimeField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.