Examples of FractionPrinterParser


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

    //-----------------------------------------------------------------------
    // print
    //-----------------------------------------------------------------------
    @Test(expectedExceptions=DateTimeException.class)
    public void test_print_emptyCalendrical() throws Exception {
        FractionPrinterParser pp = new FractionPrinterParser(NANO_OF_SECOND, 0, 9, true);
        pp.print(printEmptyContext, buf);
    }
View Full Code Here

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

        pp.print(printEmptyContext, buf);
    }

    public void test_print_append() throws Exception {
        printContext.setDateTime(LocalTime.of(12, 30, 40, 3));
        FractionPrinterParser pp = new FractionPrinterParser(NANO_OF_SECOND, 0, 9, true);
        buf.append("EXISTING");
        pp.print(printContext, buf);
        assertEquals(buf.toString(), "EXISTING.000000003");
    }
View Full Code Here

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

    }

    @Test(dataProvider="Nanos")
    public void test_print_nanos(int minWidth, int maxWidth, int value, String result) throws Exception {
        printContext.setDateTime(new MockFieldValue(NANO_OF_SECOND, value));
        FractionPrinterParser pp = new FractionPrinterParser(NANO_OF_SECOND, minWidth, maxWidth, true);
        pp.print(printContext, buf);
        if (result == null) {
            fail("Expected exception");
        }
        assertEquals(buf.toString(), result);
    }
View Full Code Here

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

    }

    @Test(dataProvider="Nanos")
    public void test_print_nanos_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception {
        printContext.setDateTime(new MockFieldValue(NANO_OF_SECOND, value));
        FractionPrinterParser pp = new FractionPrinterParser(NANO_OF_SECOND, minWidth, maxWidth, false);
        pp.print(printContext, buf);
        if (result == null) {
            fail("Expected exception");
        }
        assertEquals(buf.toString(), (result.startsWith(".") ? result.substring(1) : result));
    }
View Full Code Here

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

    }

    @Test(dataProvider="Seconds")
    public void test_print_seconds(int minWidth, int maxWidth, int value, String result) throws Exception {
        printContext.setDateTime(new MockFieldValue(SECOND_OF_MINUTE, value));
        FractionPrinterParser pp = new FractionPrinterParser(SECOND_OF_MINUTE, minWidth, maxWidth, true);
        pp.print(printContext, buf);
        if (result == null) {
            fail("Expected exception");
        }
        assertEquals(buf.toString(), result);
    }
View Full Code Here

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

    }

    @Test(dataProvider="Seconds")
    public void test_print_seconds_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception {
        printContext.setDateTime(new MockFieldValue(SECOND_OF_MINUTE, value));
        FractionPrinterParser pp = new FractionPrinterParser(SECOND_OF_MINUTE, minWidth, maxWidth, false);
        pp.print(printContext, buf);
        if (result == null) {
            fail("Expected exception");
        }
        assertEquals(buf.toString(), (result.startsWith(".") ? result.substring(1) : result));
    }
View Full Code Here

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

    //-----------------------------------------------------------------------
    // parse
    //-----------------------------------------------------------------------
    @Test(dataProvider="Nanos")
    public void test_reverseParse(int minWidth, int maxWidth, int value, String result) throws Exception {
        FractionPrinterParser pp = new FractionPrinterParser(NANO_OF_SECOND, minWidth, maxWidth, true);
        int newPos = pp.parse(parseContext, result, 0);
        assertEquals(newPos, result.length());
        int expectedValue = fixParsedValue(maxWidth, value);
        assertParsed(parseContext, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue);
    }
View Full Code Here

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

        assertParsed(parseContext, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue);
    }

    @Test(dataProvider="Nanos")
    public void test_reverseParse_noDecimalPoint(int minWidth, int maxWidth, int value, String result) throws Exception {
        FractionPrinterParser pp = new FractionPrinterParser(NANO_OF_SECOND, minWidth, maxWidth, false);
        int newPos = pp.parse(parseContext, result, (result.startsWith(".") ? 1 : 0));
        assertEquals(newPos, result.length());
        int expectedValue = fixParsedValue(maxWidth, value);
        assertParsed(parseContext, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue);
    }
View Full Code Here

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

        assertParsed(parseContext, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue);
    }

    @Test(dataProvider="Nanos")
    public void test_reverseParse_followedByNonDigit(int minWidth, int maxWidth, int value, String result) throws Exception {
        FractionPrinterParser pp = new FractionPrinterParser(NANO_OF_SECOND, minWidth, maxWidth, true);
        int newPos = pp.parse(parseContext, result + " ", 0);
        assertEquals(newPos, result.length());
        int expectedValue = fixParsedValue(maxWidth, value);
        assertParsed(parseContext, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue);
    }
View Full Code Here

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

//        assertParsed(parseContext, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue);
//    }

    @Test(dataProvider="Nanos")
    public void test_reverseParse_preceededByNonDigit(int minWidth, int maxWidth, int value, String result) throws Exception {
        FractionPrinterParser pp = new FractionPrinterParser(NANO_OF_SECOND, minWidth, maxWidth, true);
        int newPos = pp.parse(parseContext, " " + result, 1);
        assertEquals(newPos, result.length() + 1);
        int expectedValue = fixParsedValue(maxWidth, value);
        assertParsed(parseContext, NANO_OF_SECOND, value == 0 && minWidth == 0 ? null : (long) expectedValue);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.