Package org.threeten.bp.format.DateTimeFormatterBuilder

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


public class TestNumberPrinter extends AbstractTestPrinterParser {

    //-----------------------------------------------------------------------
    @Test(expectedExceptions=DateTimeException.class)
    public void test_print_emptyCalendrical() throws Exception {
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, 1, 2, SignStyle.NEVER);
        pp.print(printEmptyContext, buf);
    }
View Full Code Here


        pp.print(printEmptyContext, buf);
    }

    public void test_print_append() throws Exception {
        printContext.setDateTime(LocalDate.of(2012, 1, 3));
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, 1, 2, SignStyle.NEVER);
        buf.append("EXISTING");
        pp.print(printContext, buf);
        assertEquals(buf.toString(), "EXISTING3");
    }
View Full Code Here

    }

    @Test(dataProvider="Pad")
    public void test_pad_NOT_NEGATIVE(int minPad, int maxPad, long value, String result) throws Exception {
        printContext.setDateTime(new MockFieldValue(DAY_OF_MONTH, value));
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, minPad, maxPad, SignStyle.NOT_NEGATIVE);
        try {
            pp.print(printContext, buf);
            if (result == null || value < 0) {
                fail("Expected exception");
            }
            assertEquals(buf.toString(), result);
        } catch (DateTimeException ex) {
View Full Code Here

    }

    @Test(dataProvider="Pad")
    public void test_pad_NEVER(int minPad, int maxPad, long value, String result) throws Exception {
        printContext.setDateTime(new MockFieldValue(DAY_OF_MONTH, value));
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, minPad, maxPad, SignStyle.NEVER);
        try {
            pp.print(printContext, buf);
            if (result == null) {
                fail("Expected exception");
            }
            assertEquals(buf.toString(), result);
        } catch (DateTimeException ex) {
View Full Code Here

    }

    @Test(dataProvider="Pad")
    public void test_pad_NORMAL(int minPad, int maxPad, long value, String result) throws Exception {
        printContext.setDateTime(new MockFieldValue(DAY_OF_MONTH, value));
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, minPad, maxPad, SignStyle.NORMAL);
        try {
            pp.print(printContext, buf);
            if (result == null) {
                fail("Expected exception");
            }
            assertEquals(buf.toString(), (value < 0 ? "-" + result : result));
        } catch (DateTimeException ex) {
View Full Code Here

    }

    @Test(dataProvider="Pad")
    public void test_pad_ALWAYS(int minPad, int maxPad, long value, String result) throws Exception {
        printContext.setDateTime(new MockFieldValue(DAY_OF_MONTH, value));
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, minPad, maxPad, SignStyle.ALWAYS);
        try {
            pp.print(printContext, buf);
            if (result == null) {
                fail("Expected exception");
            }
            assertEquals(buf.toString(), (value < 0 ? "-" + result : "+" + result));
        } catch (DateTimeException ex) {
View Full Code Here

    }

    @Test(dataProvider="Pad")
    public void test_pad_EXCEEDS_PAD(int minPad, int maxPad, long value, String result) throws Exception {
        printContext.setDateTime(new MockFieldValue(DAY_OF_MONTH, value));
        NumberPrinterParser pp = new NumberPrinterParser(DAY_OF_MONTH, minPad, maxPad, SignStyle.EXCEEDS_PAD);
        try {
            pp.print(printContext, buf);
            if (result == null) {
                fail("Expected exception");
                return// unreachable
            }
            if (result.length() > minPad || value < 0) {
View Full Code Here

        }
    }

    //-----------------------------------------------------------------------
    public void test_toString1() throws Exception {
        NumberPrinterParser pp = new NumberPrinterParser(HOUR_OF_DAY, 1, 19, SignStyle.NORMAL);
        assertEquals(pp.toString(), "Value(HourOfDay)");
    }
View Full Code Here

        NumberPrinterParser pp = new NumberPrinterParser(HOUR_OF_DAY, 1, 19, SignStyle.NORMAL);
        assertEquals(pp.toString(), "Value(HourOfDay)");
    }

    public void test_toString2() throws Exception {
        NumberPrinterParser pp = new NumberPrinterParser(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE);
        assertEquals(pp.toString(), "Value(HourOfDay,2)");
    }
View Full Code Here

        NumberPrinterParser pp = new NumberPrinterParser(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE);
        assertEquals(pp.toString(), "Value(HourOfDay,2)");
    }

    public void test_toString3() throws Exception {
        NumberPrinterParser pp = new NumberPrinterParser(HOUR_OF_DAY, 1, 2, SignStyle.NOT_NEGATIVE);
        assertEquals(pp.toString(), "Value(HourOfDay,1,2,NOT_NEGATIVE)");
    }
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.