Java Code Examples for java.time.format.DateTimeFormatterBuilder#parseCaseInsensitive()

The following examples show how to use java.time.format.DateTimeFormatterBuilder#parseCaseInsensitive() . 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: TestZoneTextPrinterParser.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 2
Source File: TestZoneTextPrinterParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 3
Source File: TestZoneTextPrinterParser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 4
Source File: TestZoneTextPrinterParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 5
Source File: TestZoneTextPrinterParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 6
Source File: TestZoneTextPrinterParser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 7
Source File: TestZoneTextPrinterParser.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 8
Source File: TestZoneTextPrinterParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 9
Source File: TestZoneTextPrinterParser.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 10
Source File: TestZoneTextPrinterParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 11
Source File: TestZoneTextPrinterParser.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 12
Source File: TestZoneTextPrinterParser.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 13
Source File: TestZoneTextPrinterParser.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private DateTimeFormatter getFormatter(Locale locale, TextStyle style, boolean ci) {
    DateTimeFormatterBuilder db = new DateTimeFormatterBuilder();
    if (ci) {
        db = db.parseCaseInsensitive();
    }
    return db.appendZoneText(style)
             .toFormatter(locale)
             .withDecimalStyle(DecimalStyle.of(locale));
}
 
Example 14
Source File: JSR310DateTimeDeserializerBase.java    From jackson-modules-java8 with Apache License 2.0 4 votes vote down vote up
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
        BeanProperty property) throws JsonMappingException
{
    JsonFormat.Value format = findFormatOverrides(ctxt, property, handledType());
    JSR310DateTimeDeserializerBase<?> deser = this;
    if (format != null) {
        // 17-Aug-2019, tatu: For 2.10 let's start considering leniency/strictness too
        if (format.hasLenient()) {
            Boolean leniency = format.getLenient();
            if (leniency != null) {
                deser = deser.withLeniency(leniency);
            }
        }
        if (format.hasPattern()) {
            final String pattern = format.getPattern();
            final Locale locale = format.hasLocale() ? format.getLocale() : ctxt.getLocale();
            DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
            if (acceptCaseInsensitiveValues(ctxt, format)) {
                builder.parseCaseInsensitive();
            }
            builder.appendPattern(pattern);
            DateTimeFormatter df;
            if (locale == null) {
                df = builder.toFormatter();
            } else {
                df = builder.toFormatter(locale);
            }

            // [#148]: allow strict parsing
            if (!deser.isLenient()) {
                df = df.withResolverStyle(ResolverStyle.STRICT);
            }

            // [#69]: For instant serializers/deserializers we need to configure the formatter with
            //a time zone picked up from JsonFormat annotation, otherwise serialization might not work
            if (format.hasTimeZone()) {
                df = df.withZone(format.getTimeZone().toZoneId());
            }
            deser = deser.withDateFormat(df);
        }
        // [#58]: For LocalDate deserializers we need to configure the formatter with
        //a shape picked up from JsonFormat annotation, to decide if the value is EpochSeconds
        JsonFormat.Shape shape = format.getShape();
        if (shape != null && shape != _shape) {
            deser = deser.withShape(shape);
        }
        // any use for TimeZone?
    }
    return deser;
}