Package org.threeten.bp.format.DateTimeFormatterBuilder

Examples of org.threeten.bp.format.DateTimeFormatterBuilder.NumberPrinterParser


        pp.parse(parseContext, "--Z", 4);
    }

    //-----------------------------------------------------------------------
    public void test_parse() throws Exception {
        PadPrinterParserDecorator pp = new PadPrinterParserDecorator(new NumberPrinterParser(MONTH_OF_YEAR, 1, 3, SignStyle.NEVER), 3, '-');
        int result = pp.parse(parseContext, "--2", 0);
        assertEquals(result, 3);
        assertParsed(MONTH_OF_YEAR, 2L);
    }
View Full Code Here


        assertEquals(result, 3);
        assertParsed(MONTH_OF_YEAR, 2L);
    }

    public void test_parse_noReadBeyond() throws Exception {
        PadPrinterParserDecorator pp = new PadPrinterParserDecorator(new NumberPrinterParser(MONTH_OF_YEAR, 1, 3, SignStyle.NEVER), 3, '-');
        int result = pp.parse(parseContext, "--22", 0);
        assertEquals(result, 3);
        assertParsed(MONTH_OF_YEAR, 2L);
    }
View Full Code Here

        assertEquals(result, 3);
        assertParsed(MONTH_OF_YEAR, 2L);
    }

    public void test_parse_textLessThanPadWidth() throws Exception {
        PadPrinterParserDecorator pp = new PadPrinterParserDecorator(new NumberPrinterParser(MONTH_OF_YEAR, 1, 3, SignStyle.NEVER), 3, '-');
        int result = pp.parse(parseContext, "-1", 0);
        assertEquals(result, ~0);
    }
View Full Code Here

        int result = pp.parse(parseContext, "-1", 0);
        assertEquals(result, ~0);
    }

    public void test_parse_decoratedErrorPassedBack() throws Exception {
        PadPrinterParserDecorator pp = new PadPrinterParserDecorator(new NumberPrinterParser(MONTH_OF_YEAR, 1, 3, SignStyle.NEVER), 3, '-');
        int result = pp.parse(parseContext, "--A", 0);
        assertEquals(result, ~2);
    }
View Full Code Here

        int result = pp.parse(parseContext, "--A", 0);
        assertEquals(result, ~2);
    }

    public void test_parse_decoratedDidNotParseToPadWidth() throws Exception {
        PadPrinterParserDecorator pp = new PadPrinterParserDecorator(new NumberPrinterParser(MONTH_OF_YEAR, 1, 3, SignStyle.NEVER), 3, '-');
        int result = pp.parse(parseContext, "-1X", 0);
        assertEquals(result, ~1);
    }
View Full Code Here

    //-----------------------------------------------------------------------
    @DataProvider(name="error")
    Object[][] data_error() {
        return new Object[][] {
            {new NumberPrinterParser(DAY_OF_MONTH, 1, 2, SignStyle.NEVER), "12", -1, IndexOutOfBoundsException.class},
            {new NumberPrinterParser(DAY_OF_MONTH, 1, 2, SignStyle.NEVER), "12", 3, IndexOutOfBoundsException.class},
        };
    }
View Full Code Here

    }

    //-----------------------------------------------------------------------
    @Test(dataProvider="parseData")
    public void test_parse_fresh(int minWidth, int maxWidth, SignStyle signStyle, int subsequentWidth, String text, int pos, int expectedPos, long expectedValue) {
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, minWidth, maxWidth, signStyle);
        if (subsequentWidth > 0) {
            pp = pp.withSubsequentWidth(subsequentWidth);
        }
        int newPos = pp.parse(parseContext, text, pos);
        assertEquals(newPos, expectedPos);
        if (expectedPos > 0) {
            assertParsed(parseContext, DAY_OF_MONTH, expectedValue);
        } else {
            assertEquals(parseContext.toParsed().query(TemporalQueries.chronology()), null);
View Full Code Here

        }
    }

    @Test(dataProvider="parseData")
    public void test_parse_textField(int minWidth, int maxWidth, SignStyle signStyle, int subsequentWidth, String text, int pos, int expectedPos, long expectedValue) {
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_WEEK, minWidth, maxWidth, signStyle);
        if (subsequentWidth > 0) {
            pp = pp.withSubsequentWidth(subsequentWidth);
        }
        int newPos = pp.parse(parseContext, text, pos);
        assertEquals(newPos, expectedPos);
        if (expectedPos > 0) {
            assertParsed(parseContext, DAY_OF_WEEK, expectedValue);
        }
    }
View Full Code Here

       };
    }

    @Test(dataProvider="parseSignsStrict")
    public void test_parseSignsStrict(String input, int min, int max, SignStyle style, int parseLen, Integer parseVal) throws Exception {
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, min, max, style);
        int newPos = pp.parse(parseContext, input, 0);
        assertEquals(newPos, parseLen);
        assertParsed(parseContext, DAY_OF_MONTH, (parseVal != null ? (long) parseVal : null));
    }
View Full Code Here

    }

    @Test(dataProvider="parseSignsLenient")
    public void test_parseSignsLenient(String input, int min, int max, SignStyle style, int parseLen, Integer parseVal) throws Exception {
        parseContext.setStrict(false);
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, min, max, style);
        int newPos = pp.parse(parseContext, input, 0);
        assertEquals(newPos, parseLen);
        assertParsed(parseContext, DAY_OF_MONTH, (parseVal != null ? (long) parseVal : null));
    }
View Full Code Here

TOP

Related Classes of org.threeten.bp.format.DateTimeFormatterBuilder.NumberPrinterParser

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.