package o; import java.io.IOException; import java.text.FieldPosition; import java.text.Format; import java.text.ParseException; import java.text.ParsePosition; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Locale; import java.util.Set; import o.C15553gtn; import o.C15561gtv; import org.threeten.bp.DateTimeException; import org.threeten.bp.format.DateTimeParseException; /* renamed from: o.gto, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C15554gto { public static final C15554gto BASIC_ISO_DATE; public static final C15554gto ISO_DATE; public static final C15554gto ISO_DATE_TIME; public static final C15554gto ISO_INSTANT; public static final C15554gto ISO_LOCAL_DATE; public static final C15554gto ISO_LOCAL_DATE_TIME; public static final C15554gto ISO_LOCAL_TIME; public static final C15554gto ISO_OFFSET_DATE; public static final C15554gto ISO_OFFSET_DATE_TIME; public static final C15554gto ISO_OFFSET_TIME; public static final C15554gto ISO_ORDINAL_DATE; public static final C15554gto ISO_TIME; public static final C15554gto ISO_WEEK_DATE; public static final C15554gto ISO_ZONED_DATE_TIME; private static final gtQ PARSED_EXCESS_DAYS; private static final gtQ PARSED_LEAP_SECOND; public static final C15554gto RFC_1123_DATE_TIME; private final gsR chrono; private final C15559gtt decimalStyle; private final Locale locale; private final C15553gtn.HBt printerParser; private final Set resolverFields; private final gtA resolverStyle; private final AbstractC15502gsH zone; static { C15554gto withChronology = new C15553gtn().appendValue(EnumC15534gtD.YEAR, 4, 10, EnumC15564gty.EXCEEDS_PAD).appendLiteral('-').appendValue(EnumC15534gtD.MONTH_OF_YEAR, 2).appendLiteral('-').appendValue(EnumC15534gtD.DAY_OF_MONTH, 2).toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); ISO_LOCAL_DATE = withChronology; ISO_OFFSET_DATE = new C15553gtn().parseCaseInsensitive().append(withChronology).appendOffsetId().toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); ISO_DATE = new C15553gtn().parseCaseInsensitive().append(withChronology).optionalStart().appendOffsetId().toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); C15554gto formatter = new C15553gtn().appendValue(EnumC15534gtD.HOUR_OF_DAY, 2).appendLiteral(':').appendValue(EnumC15534gtD.MINUTE_OF_HOUR, 2).optionalStart().appendLiteral(':').appendValue(EnumC15534gtD.SECOND_OF_MINUTE, 2).optionalStart().appendFraction(EnumC15534gtD.NANO_OF_SECOND, 0, 9, true).toFormatter(gtA.STRICT); ISO_LOCAL_TIME = formatter; ISO_OFFSET_TIME = new C15553gtn().parseCaseInsensitive().append(formatter).appendOffsetId().toFormatter(gtA.STRICT); ISO_TIME = new C15553gtn().parseCaseInsensitive().append(formatter).optionalStart().appendOffsetId().toFormatter(gtA.STRICT); C15554gto withChronology2 = new C15553gtn().parseCaseInsensitive().append(withChronology).appendLiteral('T').append(formatter).toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); ISO_LOCAL_DATE_TIME = withChronology2; C15554gto withChronology3 = new C15553gtn().parseCaseInsensitive().append(withChronology2).appendOffsetId().toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); ISO_OFFSET_DATE_TIME = withChronology3; ISO_ZONED_DATE_TIME = new C15553gtn().append(withChronology3).optionalStart().appendLiteral('[').parseCaseSensitive().appendZoneRegionId().appendLiteral(']').toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); ISO_DATE_TIME = new C15553gtn().append(withChronology2).optionalStart().appendOffsetId().optionalStart().appendLiteral('[').parseCaseSensitive().appendZoneRegionId().appendLiteral(']').toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); ISO_ORDINAL_DATE = new C15553gtn().parseCaseInsensitive().appendValue(EnumC15534gtD.YEAR, 4, 10, EnumC15564gty.EXCEEDS_PAD).appendLiteral('-').appendValue(EnumC15534gtD.DAY_OF_YEAR, 3).optionalStart().appendOffsetId().toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); ISO_WEEK_DATE = new C15553gtn().parseCaseInsensitive().appendValue(gtI.WEEK_BASED_YEAR, 4, 10, EnumC15564gty.EXCEEDS_PAD).appendLiteral("-W").appendValue(gtI.WEEK_OF_WEEK_BASED_YEAR, 2).appendLiteral('-').appendValue(EnumC15534gtD.DAY_OF_WEEK, 1).optionalStart().appendOffsetId().toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); ISO_INSTANT = new C15553gtn().parseCaseInsensitive().appendInstant().toFormatter(gtA.STRICT); BASIC_ISO_DATE = new C15553gtn().parseCaseInsensitive().appendValue(EnumC15534gtD.YEAR, 4).appendValue(EnumC15534gtD.MONTH_OF_YEAR, 2).appendValue(EnumC15534gtD.DAY_OF_MONTH, 2).optionalStart().appendOffset("+HHMMss", "Z").toFormatter(gtA.STRICT).withChronology(gsV.INSTANCE); HashMap hashMap = new HashMap(); hashMap.put(1L, "Mon"); hashMap.put(2L, "Tue"); hashMap.put(3L, "Wed"); hashMap.put(4L, "Thu"); hashMap.put(5L, "Fri"); hashMap.put(6L, "Sat"); hashMap.put(7L, "Sun"); HashMap hashMap2 = new HashMap(); hashMap2.put(1L, "Jan"); hashMap2.put(2L, "Feb"); hashMap2.put(3L, "Mar"); hashMap2.put(4L, "Apr"); hashMap2.put(5L, "May"); hashMap2.put(6L, "Jun"); hashMap2.put(7L, "Jul"); hashMap2.put(8L, "Aug"); hashMap2.put(9L, "Sep"); hashMap2.put(10L, "Oct"); hashMap2.put(11L, "Nov"); hashMap2.put(12L, "Dec"); RFC_1123_DATE_TIME = new C15553gtn().parseCaseInsensitive().parseLenient().optionalStart().appendText(EnumC15534gtD.DAY_OF_WEEK, hashMap).appendLiteral(", ").optionalEnd().appendValue(EnumC15534gtD.DAY_OF_MONTH, 1, 2, EnumC15564gty.NOT_NEGATIVE).appendLiteral(' ').appendText(EnumC15534gtD.MONTH_OF_YEAR, hashMap2).appendLiteral(' ').appendValue(EnumC15534gtD.YEAR, 4).appendLiteral(' ').appendValue(EnumC15534gtD.HOUR_OF_DAY, 2).appendLiteral(':').appendValue(EnumC15534gtD.MINUTE_OF_HOUR, 2).optionalStart().appendLiteral(':').appendValue(EnumC15534gtD.SECOND_OF_MINUTE, 2).optionalEnd().appendLiteral(' ').appendOffset("+HHMM", "GMT").toFormatter(gtA.SMART).withChronology(gsV.INSTANCE); PARSED_EXCESS_DAYS = new gtQ() { // from class: o.gto.1 @Override // o.gtQ public final C15500gsA queryFrom(gtK gtk) { if (gtk instanceof C15552gtm) { return ((C15552gtm) gtk).excessDays; } return C15500gsA.ZERO; } }; PARSED_LEAP_SECOND = new gtQ() { // from class: o.gto.4 /* JADX WARN: Can't rename method to resolve collision */ @Override // o.gtQ public final Boolean queryFrom(gtK gtk) { if (gtk instanceof C15552gtm) { return Boolean.valueOf(((C15552gtm) gtk).leapSecond); } return Boolean.FALSE; } }; } public static C15554gto ofPattern(String str) { return new C15553gtn().appendPattern(str).toFormatter(); } public static C15554gto ofPattern(String str, Locale locale) { return new C15553gtn().appendPattern(str).toFormatter(locale); } public static C15554gto ofLocalizedDate(EnumC15556gtq enumC15556gtq) { gtG.requireNonNull(enumC15556gtq, "dateStyle"); return new C15553gtn().appendLocalized(enumC15556gtq, null).toFormatter().withChronology(gsV.INSTANCE); } public static C15554gto ofLocalizedTime(EnumC15556gtq enumC15556gtq) { gtG.requireNonNull(enumC15556gtq, "timeStyle"); return new C15553gtn().appendLocalized(null, enumC15556gtq).toFormatter().withChronology(gsV.INSTANCE); } public static C15554gto ofLocalizedDateTime(EnumC15556gtq enumC15556gtq) { gtG.requireNonNull(enumC15556gtq, "dateTimeStyle"); return new C15553gtn().appendLocalized(enumC15556gtq, enumC15556gtq).toFormatter().withChronology(gsV.INSTANCE); } public static C15554gto ofLocalizedDateTime(EnumC15556gtq enumC15556gtq, EnumC15556gtq enumC15556gtq2) { gtG.requireNonNull(enumC15556gtq, "dateStyle"); gtG.requireNonNull(enumC15556gtq2, "timeStyle"); return new C15553gtn().appendLocalized(enumC15556gtq, enumC15556gtq2).toFormatter().withChronology(gsV.INSTANCE); } /* JADX INFO: Access modifiers changed from: package-private */ public C15554gto(C15553gtn.HBt hBt, Locale locale, C15559gtt c15559gtt, gtA gta, Set set, gsR gsr, AbstractC15502gsH abstractC15502gsH) { this.printerParser = (C15553gtn.HBt) gtG.requireNonNull(hBt, "printerParser"); this.locale = (Locale) gtG.requireNonNull(locale, "locale"); this.decimalStyle = (C15559gtt) gtG.requireNonNull(c15559gtt, "decimalStyle"); this.resolverStyle = (gtA) gtG.requireNonNull(gta, "resolverStyle"); this.resolverFields = set; this.chrono = gsr; this.zone = abstractC15502gsH; } public final C15554gto withLocale(Locale locale) { return this.locale.equals(locale) ? this : new C15554gto(this.printerParser, locale, this.decimalStyle, this.resolverStyle, this.resolverFields, this.chrono, this.zone); } public final C15554gto withDecimalStyle(C15559gtt c15559gtt) { return this.decimalStyle.equals(c15559gtt) ? this : new C15554gto(this.printerParser, this.locale, c15559gtt, this.resolverStyle, this.resolverFields, this.chrono, this.zone); } public final C15554gto withChronology(gsR gsr) { return gtG.equals(this.chrono, gsr) ? this : new C15554gto(this.printerParser, this.locale, this.decimalStyle, this.resolverStyle, this.resolverFields, gsr, this.zone); } public final C15554gto withZone(AbstractC15502gsH abstractC15502gsH) { return gtG.equals(this.zone, abstractC15502gsH) ? this : new C15554gto(this.printerParser, this.locale, this.decimalStyle, this.resolverStyle, this.resolverFields, this.chrono, abstractC15502gsH); } public final C15554gto withResolverStyle(gtA gta) { gtG.requireNonNull(gta, "resolverStyle"); return gtG.equals(this.resolverStyle, gta) ? this : new C15554gto(this.printerParser, this.locale, this.decimalStyle, gta, this.resolverFields, this.chrono, this.zone); } public final C15554gto withResolverFields(InterfaceC15537gtP... interfaceC15537gtPArr) { if (interfaceC15537gtPArr == null) { return new C15554gto(this.printerParser, this.locale, this.decimalStyle, this.resolverStyle, null, this.chrono, this.zone); } HashSet hashSet = new HashSet(Arrays.asList(interfaceC15537gtPArr)); if (gtG.equals(this.resolverFields, hashSet)) { return this; } return new C15554gto(this.printerParser, this.locale, this.decimalStyle, this.resolverStyle, Collections.unmodifiableSet(hashSet), this.chrono, this.zone); } public final C15554gto withResolverFields(Set set) { if (set == null) { return new C15554gto(this.printerParser, this.locale, this.decimalStyle, this.resolverStyle, null, this.chrono, this.zone); } if (gtG.equals(this.resolverFields, set)) { return this; } return new C15554gto(this.printerParser, this.locale, this.decimalStyle, this.resolverStyle, Collections.unmodifiableSet(new HashSet(set)), this.chrono, this.zone); } public final String format(gtK gtk) { StringBuilder sb = new StringBuilder(32); formatTo(gtk, sb); return sb.toString(); } public final void formatTo(gtK gtk, Appendable appendable) { gtG.requireNonNull(gtk, "temporal"); gtG.requireNonNull(appendable, "appendable"); try { C15560gtu c15560gtu = new C15560gtu(gtk, this); if (appendable instanceof StringBuilder) { this.printerParser.print(c15560gtu, (StringBuilder) appendable); return; } StringBuilder sb = new StringBuilder(32); this.printerParser.print(c15560gtu, sb); appendable.append(sb); } catch (IOException e) { throw new DateTimeException(e.getMessage(), e); } } public final gtK parse(CharSequence charSequence) { gtG.requireNonNull(charSequence, "text"); try { return parseToBuilder(charSequence, null).resolve(this.resolverStyle, this.resolverFields); } catch (DateTimeParseException e) { throw e; } catch (RuntimeException e2) { throw createError(charSequence, e2); } } public final gtK parse(CharSequence charSequence, ParsePosition parsePosition) { gtG.requireNonNull(charSequence, "text"); gtG.requireNonNull(parsePosition, "position"); try { return parseToBuilder(charSequence, parsePosition).resolve(this.resolverStyle, this.resolverFields); } catch (IndexOutOfBoundsException e) { throw e; } catch (DateTimeParseException e2) { throw e2; } catch (RuntimeException e3) { throw createError(charSequence, e3); } } public final T parse(CharSequence charSequence, gtQ gtq) { gtG.requireNonNull(charSequence, "text"); gtG.requireNonNull(gtq, "type"); try { return (T) parseToBuilder(charSequence, null).resolve(this.resolverStyle, this.resolverFields).build(gtq); } catch (DateTimeParseException e) { throw e; } catch (RuntimeException e2) { throw createError(charSequence, e2); } } public final gtK parseBest(CharSequence charSequence, gtQ... gtqArr) { gtG.requireNonNull(charSequence, "text"); gtG.requireNonNull(gtqArr, "types"); if (gtqArr.length < 2) { throw new IllegalArgumentException("At least two types must be specified"); } try { try { C15552gtm resolve = parseToBuilder(charSequence, null).resolve(this.resolverStyle, this.resolverFields); for (gtQ gtq : gtqArr) { try { return (gtK) resolve.build(gtq); } catch (RuntimeException unused) { } } StringBuilder sb = new StringBuilder(); sb.append("Unable to convert parsed text to any specified type: "); sb.append(Arrays.toString(gtqArr)); throw new DateTimeException(sb.toString()); } catch (RuntimeException e) { throw createError(charSequence, e); } } catch (DateTimeParseException e2) { throw e2; } } private DateTimeParseException createError(CharSequence charSequence, RuntimeException runtimeException) { String obj; if (charSequence.length() > 64) { StringBuilder sb = new StringBuilder(); sb.append(charSequence.subSequence(0, 64).toString()); sb.append("..."); obj = sb.toString(); } else { obj = charSequence.toString(); } StringBuilder sb2 = new StringBuilder("Text '"); sb2.append(obj); sb2.append("' could not be parsed: "); sb2.append(runtimeException.getMessage()); return new DateTimeParseException(sb2.toString(), charSequence, 0, runtimeException); } /* JADX INFO: Access modifiers changed from: private */ public C15552gtm parseToBuilder(CharSequence charSequence, ParsePosition parsePosition) { String obj; ParsePosition parsePosition2 = parsePosition != null ? parsePosition : new ParsePosition(0); C15561gtv.IeS parseUnresolved0 = parseUnresolved0(charSequence, parsePosition2); if (parseUnresolved0 == null || parsePosition2.getErrorIndex() >= 0 || (parsePosition == null && parsePosition2.getIndex() < charSequence.length())) { if (charSequence.length() > 64) { StringBuilder sb = new StringBuilder(); sb.append(charSequence.subSequence(0, 64).toString()); sb.append("..."); obj = sb.toString(); } else { obj = charSequence.toString(); } if (parsePosition2.getErrorIndex() >= 0) { StringBuilder sb2 = new StringBuilder("Text '"); sb2.append(obj); sb2.append("' could not be parsed at index "); sb2.append(parsePosition2.getErrorIndex()); throw new DateTimeParseException(sb2.toString(), charSequence, parsePosition2.getErrorIndex()); } StringBuilder sb3 = new StringBuilder("Text '"); sb3.append(obj); sb3.append("' could not be parsed, unparsed text found at index "); sb3.append(parsePosition2.getIndex()); throw new DateTimeParseException(sb3.toString(), charSequence, parsePosition2.getIndex()); } return parseUnresolved0.toBuilder(); } public final gtK parseUnresolved(CharSequence charSequence, ParsePosition parsePosition) { return parseUnresolved0(charSequence, parsePosition); } /* JADX INFO: Access modifiers changed from: private */ public C15561gtv.IeS parseUnresolved0(CharSequence charSequence, ParsePosition parsePosition) { gtG.requireNonNull(charSequence, "text"); gtG.requireNonNull(parsePosition, "position"); C15561gtv c15561gtv = new C15561gtv(this); int parse = this.printerParser.parse(c15561gtv, charSequence, parsePosition.getIndex()); if (parse < 0) { parsePosition.setErrorIndex(~parse); return null; } parsePosition.setIndex(parse); return c15561gtv.toParsed(); } /* JADX INFO: Access modifiers changed from: package-private */ public final C15553gtn.HBt toPrinterParser(boolean z) { return this.printerParser.withOptional(z); } public final Format toFormat() { return new Sts(this, null); } public final Format toFormat(gtQ gtq) { gtG.requireNonNull(gtq, "query"); return new Sts(this, gtq); } public final String toString() { String obj = this.printerParser.toString(); return !obj.startsWith("[") ? obj.substring(1, obj.length() - 1) : obj; } /* renamed from: o.gto$Sts */ /* loaded from: classes6.dex */ static class Sts extends Format { private final C15554gto formatter; private final gtQ query; public Sts(C15554gto c15554gto, gtQ gtq) { this.formatter = c15554gto; this.query = gtq; } @Override // java.text.Format public final StringBuffer format(Object obj, StringBuffer stringBuffer, FieldPosition fieldPosition) { gtG.requireNonNull(obj, "obj"); gtG.requireNonNull(stringBuffer, "toAppendTo"); gtG.requireNonNull(fieldPosition, "pos"); if (!(obj instanceof gtK)) { throw new IllegalArgumentException("Format target must implement TemporalAccessor"); } fieldPosition.setBeginIndex(0); fieldPosition.setEndIndex(0); try { this.formatter.formatTo((gtK) obj, stringBuffer); return stringBuffer; } catch (RuntimeException e) { throw new IllegalArgumentException(e.getMessage(), e); } } @Override // java.text.Format public final Object parseObject(String str) throws ParseException { gtG.requireNonNull(str, "text"); try { gtQ gtq = this.query; if (gtq == null) { return this.formatter.parseToBuilder(str, null).resolve(this.formatter.getResolverStyle(), this.formatter.getResolverFields()); } return this.formatter.parse(str, gtq); } catch (DateTimeParseException e) { throw new ParseException(e.getMessage(), e.getErrorIndex()); } catch (RuntimeException e2) { throw ((ParseException) new ParseException(e2.getMessage(), 0).initCause(e2)); } } @Override // java.text.Format public final Object parseObject(String str, ParsePosition parsePosition) { gtG.requireNonNull(str, "text"); try { C15561gtv.IeS parseUnresolved0 = this.formatter.parseUnresolved0(str, parsePosition); if (parseUnresolved0 == null) { if (parsePosition.getErrorIndex() < 0) { parsePosition.setErrorIndex(0); } return null; } try { C15552gtm resolve = parseUnresolved0.toBuilder().resolve(this.formatter.getResolverStyle(), this.formatter.getResolverFields()); gtQ gtq = this.query; return gtq == null ? resolve : resolve.build(gtq); } catch (RuntimeException unused) { parsePosition.setErrorIndex(0); return null; } } catch (IndexOutOfBoundsException unused2) { if (parsePosition.getErrorIndex() < 0) { parsePosition.setErrorIndex(0); } return null; } } } public final AbstractC15502gsH getZone() { return this.zone; } public final gtA getResolverStyle() { return this.resolverStyle; } public final Set getResolverFields() { return this.resolverFields; } public final Locale getLocale() { return this.locale; } public final C15559gtt getDecimalStyle() { return this.decimalStyle; } public final gsR getChronology() { return this.chrono; } public static final gtQ parsedLeapSecond() { return PARSED_LEAP_SECOND; } public static final gtQ parsedExcessDays() { return PARSED_EXCESS_DAYS; } }