Package org.threeten.bp.format

Examples of org.threeten.bp.format.DateTimeFormatter$ClassicFormat


        result("LocalT-Q", end - start);
    }

    private static void formatListTime(List<LocalTime> list) {
        StringBuilder buf = new StringBuilder();
        DateTimeFormatter format = DateTimeFormatter.ISO_TIME.withLocale(Locale.ENGLISH);
        long start = System.nanoTime();
        for (LocalTime dt : list) {
            buf.setLength(0);
            buf.append(format.format(dt));
        }
        long end = System.nanoTime();
        System.out.println("LocalT:    Format: " + NF.format(end - start) + " ns" + " " + buf);
        result("LocalT-P", end - start);
    }
View Full Code Here


        result("ZonedDT-Q", end - start);
    }

    private static void formatListZonedDateTime(List<ZonedDateTime> list) {
        StringBuilder buf = new StringBuilder();
        DateTimeFormatter format = DateTimeFormatter.ISO_DATE.withLocale(Locale.ENGLISH);
        long start = System.nanoTime();
        for (ZonedDateTime dt : list) {
            buf.setLength(0);
            buf.append(format.format(dt));
        }
        long end = System.nanoTime();
        System.out.println("ZonedDT:   Format: " + NF.format(end - start) + " ns" + " " + buf);
        result("ZonedDT-P", end - start);
    }
View Full Code Here

    //-----------------------------------------------------------------------
    // parse weeks
    //-----------------------------------------------------------------------
    @Test(dataProvider="week")
    public void test_parse_weeks(LocalDate date, DayOfWeek dow, int week, int wby) {
        DateTimeFormatter f = new DateTimeFormatterBuilder()
                .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-')
                .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-')
                .appendValue(DAY_OF_WEEK).toFormatter();
        LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f);
        assertEquals(parsed, date);
View Full Code Here

    //-----------------------------------------------------------------------
    // parse(DateTimeFormatter)
    //-----------------------------------------------------------------------
    @Test
    public void factory_parse_formatter() {
        DateTimeFormatter f = DateTimeFormatter.ofPattern("u M");
        YearMonth test = YearMonth.parse("2010 12", f);
        assertEquals(test, YearMonth.of(2010, 12));
    }
View Full Code Here

        assertEquals(test, YearMonth.of(2010, 12));
    }

    @Test(expectedExceptions=NullPointerException.class)
    public void factory_parse_formatter_nullText() {
        DateTimeFormatter f = DateTimeFormatter.ofPattern("u M");
        YearMonth.parse((String) null, f);
    }
View Full Code Here

    //-----------------------------------------------------------------------
    // format(DateTimeFormatter)
    //-----------------------------------------------------------------------
    @Test
    public void test_format_formatter() {
        DateTimeFormatter f = DateTimeFormatter.ofPattern("y M");
        String t = YearMonth.of(2010, 12).format(f);
        assertEquals(t, "2010 12");
    }
View Full Code Here

    //-----------------------------------------------------------------------
    // parse(DateTimeFormatter)
    //-----------------------------------------------------------------------
    @Test
    public void factory_parse_formatter() {
        DateTimeFormatter f = DateTimeFormatter.ofPattern("u M d H m s XXX");
        OffsetDateTime test = OffsetDateTime.parse("2010 12 3 11 30 0 +01:00", f);
        assertEquals(test, OffsetDateTime.of(LocalDate.of(2010, 12, 3), LocalTime.of(11, 30), ZoneOffset.ofHours(1)));
    }
View Full Code Here

        assertEquals(test, OffsetDateTime.of(LocalDate.of(2010, 12, 3), LocalTime.of(11, 30), ZoneOffset.ofHours(1)));
    }

    @Test(expectedExceptions=NullPointerException.class)
    public void factory_parse_formatter_nullText() {
        DateTimeFormatter f = DateTimeFormatter.ofPattern("u M d H m s");
        OffsetDateTime.parse((String) null, f);
    }
View Full Code Here

    //-----------------------------------------------------------------------
    // format(DateTimeFormatter)
    //-----------------------------------------------------------------------
    @Test
    public void test_format_formatter() {
        DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s");
        String t = OffsetDateTime.of(LocalDate.of(2010, 12, 3), LocalTime.of(11, 30), OFFSET_PONE).format(f);
        assertEquals(t, "2010 12 3 11 30 0");
    }
View Full Code Here

    //-----------------------------------------------------------------------
    // parse(DateTimeFormatter)
    //-----------------------------------------------------------------------
    @Test
    public void factory_parse_formatter() {
        DateTimeFormatter f = DateTimeFormatter.ofPattern("u M d");
        LocalDate test = LocalDate.parse("2010 12 3", f);
        assertEquals(test, LocalDate.of(2010, 12, 3));
    }
View Full Code Here

TOP

Related Classes of org.threeten.bp.format.DateTimeFormatter$ClassicFormat

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.