Java Code Examples for org.threeten.bp.LocalDate#parse()

The following examples show how to use org.threeten.bp.LocalDate#parse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSON.java    From huaweicloud-cs-sdk with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 2
Source File: TestIsoFields.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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);
}
 
Example 3
Source File: JSON.java    From oxd with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 4
Source File: LocalDateConverterTest.java    From ThreeTen-Backport-Gson-Adapter with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerialization() {
    LocalDate localDate = LocalDate.parse("2010-08-20");

    String json = gson.toJson(localDate);

    assertEquals(json, "\"2010-08-20\"");
}
 
Example 5
Source File: JSON.java    From swagger-aem with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 6
Source File: JSON.java    From swaggy-jenkins with MIT License 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 7
Source File: JSON.java    From nifi-swagger-client with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 8
Source File: JSON.java    From android with MIT License 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 9
Source File: JSON.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 10
Source File: JSON.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 11
Source File: JSON.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 12
Source File: JSON.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 13
Source File: JSON.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 14
Source File: JSON.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 15
Source File: JSON.java    From huaweicloud-cs-sdk with Apache License 2.0 5 votes vote down vote up
@Override
public LocalDate read(JsonReader in) throws IOException {
    switch (in.peek()) {
        case NULL:
            in.nextNull();
            return null;
        default:
            String date = in.nextString();
            return LocalDate.parse(date, formatter);
    }
}
 
Example 16
Source File: TestDateTimeFormatters.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expectedExceptions = DateTimeException.class)
public void test_parse_isoLocalDate_1000000000_failedCreate() {
    LocalDate.parse("+1000000000-08-06");
}
 
Example 17
Source File: TestDateTimeFormatters.java    From threetenbp with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Test(expectedExceptions = DateTimeException.class)
public void test_parse_isoLocalDate_M1000000000_failedCreate() {
    LocalDate.parse("-1000000000-08-06");
}