Package javax.time.calendar.format

Examples of javax.time.calendar.format.CalendricalParseException


                    case 'H': values.hours = parseInt(values, value, baseIndex) ; break;
                    case 'M': values.minutes = parseInt(values, value, baseIndex) ; break;
                    case 'S': values.seconds = parseInt(values, value, baseIndex) ; break;
                    case 'N': values.nanos = parseNanos(values, value, baseIndex); break;
                    default:
                        throw new CalendricalParseException("Period could not be parsed, unrecognized letter '" +
                                c + "': " + values.text, values.text, baseIndex + values.index);
                }
                values.index++;
            }
        }
View Full Code Here


        }
    }

    private long parseNanos(ParseValues values, String s, int baseIndex) {
        if (s.length() > 9) {
            throw new CalendricalParseException("Period could not be parsed, nanosecond range exceeded: " +
                    values.text, values.text, baseIndex + values.index - s.length());
        }
        // pad to the right to create 10**9, then trim
        return Long.parseLong((s + "000000000").substring(0, 9));
    }
View Full Code Here

           
            // verify that the first character after the dot is a digit
            if (Character.isDigit(s.charAt(i))) {
                i++;
            } else {
                throw new CalendricalParseException("Period could not be parsed, invalid decimal number: " +
                        values.text, values.text, baseIndex + values.index);
            }
           
            // verify that only digits follow the decimal point followed by an S
            while (i < s.length()) {
                // || !Character.isDigit(s.charAt(i))
                char c = s.charAt(i);
                if (Character.isDigit(c) || c == 'S') {
                    i++;
                } else {
                    throw new CalendricalParseException("Period could not be parsed, invalid decimal number: " +
                            values.text, values.text, baseIndex + values.index);
                }
            }
            s = s.replace('S', 'N').replace('.', 'S');
            if (s.contains("-0S")) {
View Full Code Here

    private int parseInt(ParseValues values, String s, int baseIndex) {
        try {
            int value = Integer.parseInt(s);
            if (s.charAt(0) == '-' && value == 0) {
                throw new CalendricalParseException("Period could not be parsed, invalid number '" +
                        s + "': " + values.text, values.text, baseIndex + values.index - s.length());
            }
            return value;
        } catch (NumberFormatException ex) {
            throw new CalendricalParseException("Period could not be parsed, invalid number '" +
                    s + "': " + values.text, values.text, baseIndex + values.index - s.length());
        }
    }
View Full Code Here

        char[] chars = s.toCharArray();
        int tokenPos = 0;
        boolean lastLetter = false;
        for (int i = 0; i < chars.length; i++) {
            if (tokenPos >= TOKEN_SEQUENCE.length()) {
                throw new CalendricalParseException("Period could not be parsed, characters after last 'S': " + text, text, i);
            }
            char c = chars[i];
            if ((c < '0' || c > '9') && c != '-' && c != '.') {
                tokenPos = TOKEN_SEQUENCE.indexOf(c, tokenPos);
                if (tokenPos < 0) {
                    throw new CalendricalParseException("Period could not be parsed, invalid character '" + c + "': " + text, text, i);
                }
                tokenPos++;
                lastLetter = true;
            } else {
                lastLetter = false;
            }
        }
        if (lastLetter == false) {
            throw new CalendricalParseException("Period could not be parsed, invalid last character: " + text, text, s.length() - 1);
        }
    }
View Full Code Here

TOP

Related Classes of javax.time.calendar.format.CalendricalParseException

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.