package o; import java.io.IOException; import java.io.ObjectInputStream; import java.io.Serializable; import java.text.DateFormatSymbols; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.Locale; import java.util.TimeZone; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /* loaded from: classes6.dex */ public final class gjU implements Serializable { private static final tOB[] e = new tOB[0]; private static final ConcurrentMap f = new ConcurrentHashMap(7); public final Locale a; final String b; public transient int c; public final TimeZone d; private transient tOB[] h; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public interface LWm extends tOB { void c(Appendable appendable, int i) throws IOException; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public interface tOB { void b(Appendable appendable, Calendar calendar) throws IOException; int c(); } /* JADX INFO: Access modifiers changed from: protected */ public gjU(String str, TimeZone timeZone, Locale locale) { this.b = str; this.d = timeZone; this.a = gjH.b(locale); a(); } private void a() { tOB[] tobArr = (tOB[]) b().toArray(e); this.h = tobArr; int length = tobArr.length; int i = 0; while (true) { length--; if (length < 0) { this.c = i; return; } i += this.h[length].c(); } } /* JADX WARN: Failed to find 'out' block for switch in B:10:0x0052. Please report as an issue. */ /* JADX WARN: Failed to find 'out' block for switch in B:12:0x0056. Please report as an issue. */ /* JADX WARN: Failed to find 'out' block for switch in B:13:0x0059. Please report as an issue. */ private List b() { int i; boolean z; tOB d; int i2; tOB sax; tOB d2; DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(this.a); ArrayList arrayList = new ArrayList(); String[] eras = dateFormatSymbols.getEras(); String[] months = dateFormatSymbols.getMonths(); String[] shortMonths = dateFormatSymbols.getShortMonths(); String[] weekdays = dateFormatSymbols.getWeekdays(); String[] shortWeekdays = dateFormatSymbols.getShortWeekdays(); String[] amPmStrings = dateFormatSymbols.getAmPmStrings(); int length = this.b.length(); int[] iArr = new int[1]; int i3 = 0; int i4 = 0; while (i4 < length) { iArr[i3] = i4; String a = a(this.b, iArr); int i5 = iArr[i3]; int length2 = a.length(); if (length2 == 0) { return arrayList; } char charAt = a.charAt(i3); if (charAt != 'y') { if (charAt != 'z') { switch (charAt) { case '\'': String substring = a.substring(1); if (substring.length() == 1) { i2 = 0; sax = new Sts(substring.charAt(0)); } else { i2 = 0; sax = new saX(substring); } d = sax; i = i2; break; case 'K': d2 = d(10, length2); d = d2; i = 0; break; case 'M': if (length2 >= 4) { d2 = new ojQ(2, months); } else if (length2 == 3) { d2 = new ojQ(2, shortMonths); } else if (length2 == 2) { d2 = vUG.b; } else { d2 = CeN.b; } d = d2; i = 0; break; case 'S': d2 = d(14, length2); d = d2; i = 0; break; case 'a': d2 = new ojQ(9, amPmStrings); d = d2; i = 0; break; case 'd': d2 = d(5, length2); d = d2; i = 0; break; case 'h': d = new ZnX(d(10, length2)); i = 0; break; case 'k': d2 = new dAO(d(11, length2)); d = d2; i = 0; break; case 'm': d2 = d(12, length2); d = d2; i = 0; break; case 's': d2 = d(13, length2); d = d2; i = 0; break; case 'u': d2 = new RVV(d(7, length2)); d = d2; i = 0; break; case 'w': d2 = d(3, length2); d = d2; i = 0; break; default: i = 0; switch (charAt) { case 'D': d2 = d(6, length2); d = d2; i = 0; break; case 'E': d = new ojQ(7, length2 < 4 ? shortWeekdays : weekdays); i = 0; break; case 'F': d2 = d(8, length2); d = d2; i = 0; break; case 'G': d = new ojQ(0, eras); break; case 'H': d = d(11, length2); break; default: switch (charAt) { case 'W': d2 = d(4, length2); d = d2; i = 0; break; case 'X': d2 = HBt.b(length2); d = d2; i = 0; break; case 'Y': break; case 'Z': if (length2 == 1) { d2 = jNh.b; } else if (length2 == 2) { d2 = HBt.d; } else { d2 = jNh.d; } d = d2; i = 0; break; default: throw new IllegalArgumentException("Illegal pattern component: ".concat(String.valueOf(a))); } } } } else if (length2 >= 4) { d = new ZqN(this.d, this.a, 1); z = true; i = 0; arrayList.add(d); i3 = i; i4 = i5 + 1; } else { d = new ZqN(this.d, this.a, 0); i = 0; } z = true; arrayList.add(d); i3 = i; i4 = i5 + 1; } i = 0; if (length2 == 2) { d = Heg.e; z = true; } else { z = true; d = d(1, Math.max(length2, 4)); } if (charAt == 'Y') { d = new Plv((LWm) d); } arrayList.add(d); i3 = i; i4 = i5 + 1; } return arrayList; } private static String a(String str, int[] iArr) { StringBuilder sb = new StringBuilder(); int i = iArr[0]; int length = str.length(); char charAt = str.charAt(i); if ((charAt >= 'A' && charAt <= 'Z') || (charAt >= 'a' && charAt <= 'z')) { sb.append(charAt); while (true) { int i2 = i + 1; if (i2 >= length || str.charAt(i2) != charAt) { break; } sb.append(charAt); i = i2; } } else { sb.append('\''); boolean z = false; while (i < length) { char charAt2 = str.charAt(i); if (charAt2 != '\'') { if (!z && ((charAt2 >= 'A' && charAt2 <= 'Z') || (charAt2 >= 'a' && charAt2 <= 'z'))) { i--; break; } sb.append(charAt2); } else { int i3 = i + 1; if (i3 >= length || str.charAt(i3) != '\'') { z = !z; } else { sb.append(charAt2); i = i3; } } i++; } } iArr[0] = i; return sb.toString(); } private static LWm d(int i, int i2) { if (i2 == 1) { return new mxa(i); } if (i2 == 2) { return new NHB(i); } return new IeS(i, i2); } public final B d(Calendar calendar, B b) { try { for (tOB tob : this.h) { tob.b(b, calendar); } } catch (IOException e2) { C15178gjQ.c(e2); } return b; } public final boolean equals(Object obj) { if (!(obj instanceof gjU)) { return false; } gjU gju = (gjU) obj; return this.b.equals(gju.b) && this.d.equals(gju.d) && this.a.equals(gju.a); } public final int hashCode() { return this.b.hashCode() + ((this.d.hashCode() + (this.a.hashCode() * 13)) * 13); } public final String toString() { StringBuilder sb = new StringBuilder("FastDatePrinter["); sb.append(this.b); sb.append(","); sb.append(this.a); sb.append(","); sb.append(this.d.getID()); sb.append("]"); return sb.toString(); } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); a(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class Sts implements tOB { private final char d; @Override // o.gjU.tOB public final int c() { return 1; } Sts(char c) { this.d = c; } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { appendable.append(this.d); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class saX implements tOB { private final String c; saX(String str) { this.c = str; } @Override // o.gjU.tOB public final int c() { return this.c.length(); } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { appendable.append(this.c); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class ojQ implements tOB { private final int b; private final String[] e; ojQ(int i, String[] strArr) { this.b = i; this.e = strArr; } @Override // o.gjU.tOB public final int c() { int length = this.e.length; int i = 0; while (true) { length--; if (length < 0) { return i; } int length2 = this.e[length].length(); if (length2 > i) { i = length2; } } } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { appendable.append(this.e[calendar.get(this.b)]); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class mxa implements LWm { private final int c; @Override // o.gjU.tOB public final int c() { return 4; } mxa(int i) { this.c = i; } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { c(appendable, calendar.get(this.c)); } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { if (i < 10) { appendable.append((char) (i + 48)); } else if (i < 100) { gjU.b(appendable, i); } else { gjU.b(appendable, i, 1); } } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class CeN implements LWm { static final CeN b = new CeN(); @Override // o.gjU.tOB public final int c() { return 2; } CeN() { } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { int i = calendar.get(2); int i2 = i + 1; if (i2 < 10) { appendable.append((char) (i + 49)); } else { gjU.b(appendable, i2); } } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { if (i < 10) { appendable.append((char) (i + 48)); } else { gjU.b(appendable, i); } } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class IeS implements LWm { private final int a; private final int d; IeS(int i, int i2) { if (i2 < 3) { throw new IllegalArgumentException(); } this.d = i; this.a = i2; } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { gjU.b(appendable, calendar.get(this.d), this.a); } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { gjU.b(appendable, i, this.a); } @Override // o.gjU.tOB public final int c() { return this.a; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class NHB implements LWm { private final int b; @Override // o.gjU.tOB public final int c() { return 2; } NHB(int i) { this.b = i; } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { int i = calendar.get(this.b); if (i < 100) { gjU.b(appendable, i); } else { gjU.b(appendable, i, 2); } } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { if (i < 100) { gjU.b(appendable, i); } else { gjU.b(appendable, i, 2); } } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class Heg implements LWm { static final Heg e = new Heg(); @Override // o.gjU.tOB public final int c() { return 2; } Heg() { } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { gjU.b(appendable, (calendar.get(1) % 100) % 100); } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { gjU.b(appendable, i % 100); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class vUG implements LWm { static final vUG b = new vUG(); @Override // o.gjU.tOB public final int c() { return 2; } vUG() { } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { gjU.b(appendable, calendar.get(2) + 1); } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { gjU.b(appendable, i); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class ZnX implements LWm { private final LWm c; ZnX(LWm lWm) { this.c = lWm; } @Override // o.gjU.tOB public final int c() { return this.c.c(); } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { int i = calendar.get(10); if (i == 0) { i = calendar.getLeastMaximum(10) + 1; } this.c.c(appendable, i); } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { this.c.c(appendable, i); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class dAO implements LWm { private final LWm c; dAO(LWm lWm) { this.c = lWm; } @Override // o.gjU.tOB public final int c() { return this.c.c(); } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { int i = calendar.get(11); if (i == 0) { i = calendar.getMaximum(11) + 1; } this.c.c(appendable, i); } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { this.c.c(appendable, i); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class RVV implements LWm { private final LWm b; RVV(LWm lWm) { this.b = lWm; } @Override // o.gjU.tOB public final int c() { return this.b.c(); } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { int i = calendar.get(7); this.b.c(appendable, i != 1 ? i - 1 : 7); } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { this.b.c(appendable, i); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class Plv implements LWm { private final LWm b; Plv(LWm lWm) { this.b = lWm; } @Override // o.gjU.tOB public final int c() { return this.b.c(); } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { this.b.c(appendable, calendar.getWeekYear()); } @Override // o.gjU.LWm public final void c(Appendable appendable, int i) throws IOException { this.b.c(appendable, i); } } static String e(TimeZone timeZone, boolean z, int i, Locale locale) { jbe jbeVar = new jbe(timeZone, z, i, locale); ConcurrentMap concurrentMap = f; String str = concurrentMap.get(jbeVar); if (str != null) { return str; } String displayName = timeZone.getDisplayName(z, i, locale); String putIfAbsent = concurrentMap.putIfAbsent(jbeVar, displayName); return putIfAbsent != null ? putIfAbsent : displayName; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class ZqN implements tOB { private final Locale a; private final int b; private final String d; private final String e; ZqN(TimeZone timeZone, Locale locale, int i) { this.a = gjH.b(locale); this.b = i; this.e = gjU.e(timeZone, false, i, locale); this.d = gjU.e(timeZone, true, i, locale); } @Override // o.gjU.tOB public final int c() { return Math.max(this.e.length(), this.d.length()); } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { TimeZone timeZone = calendar.getTimeZone(); if (calendar.get(16) == 0) { appendable.append(gjU.e(timeZone, false, this.b, this.a)); } else { appendable.append(gjU.e(timeZone, true, this.b, this.a)); } } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class jNh implements tOB { private boolean e; static final jNh d = new jNh(true); static final jNh b = new jNh(false); @Override // o.gjU.tOB public final int c() { return 5; } private jNh(boolean z) { this.e = z; } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { int i = calendar.get(15) + calendar.get(16); if (i < 0) { appendable.append('-'); i = -i; } else { appendable.append('+'); } int i2 = i / 3600000; gjU.b(appendable, i2); if (this.e) { appendable.append(':'); } gjU.b(appendable, (i / 60000) - (i2 * 60)); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class HBt implements tOB { private int c; private static HBt e = new HBt(3); private static HBt b = new HBt(5); static final HBt d = new HBt(6); static HBt b(int i) { if (i == 1) { return e; } if (i == 2) { return b; } if (i == 3) { return d; } throw new IllegalArgumentException("invalid number of X"); } private HBt(int i) { this.c = i; } @Override // o.gjU.tOB public final void b(Appendable appendable, Calendar calendar) throws IOException { int i = calendar.get(15) + calendar.get(16); if (i == 0) { appendable.append("Z"); return; } if (i < 0) { appendable.append('-'); i = -i; } else { appendable.append('+'); } int i2 = i / 3600000; gjU.b(appendable, i2); int i3 = this.c; if (i3 < 5) { return; } if (i3 == 6) { appendable.append(':'); } gjU.b(appendable, (i / 60000) - (i2 * 60)); } @Override // o.gjU.tOB public final int c() { return this.c; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class jbe { private final TimeZone a; private final int b; private final Locale c; jbe(TimeZone timeZone, boolean z, int i, Locale locale) { this.a = timeZone; if (z) { this.b = Integer.MIN_VALUE | i; } else { this.b = i; } this.c = gjH.b(locale); } public final int hashCode() { return (((this.b * 31) + this.c.hashCode()) * 31) + this.a.hashCode(); } public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof jbe)) { return false; } jbe jbeVar = (jbe) obj; return this.a.equals(jbeVar.a) && this.b == jbeVar.b && this.c.equals(jbeVar.c); } } static /* synthetic */ void b(Appendable appendable, int i) throws IOException { appendable.append((char) ((i / 10) + 48)); appendable.append((char) ((i % 10) + 48)); } static /* synthetic */ void b(Appendable appendable, int i, int i2) throws IOException { if (i < 10000) { int i3 = i < 1000 ? i < 100 ? i < 10 ? 1 : 2 : 3 : 4; for (int i4 = i2 - i3; i4 > 0; i4--) { appendable.append('0'); } if (i3 != 1) { if (i3 != 2) { if (i3 != 3) { if (i3 != 4) { return; } appendable.append((char) ((i / 1000) + 48)); i %= 1000; } if (i >= 100) { appendable.append((char) ((i / 100) + 48)); i %= 100; } else { appendable.append('0'); } } if (i >= 10) { appendable.append((char) ((i / 10) + 48)); i %= 10; } else { appendable.append('0'); } } appendable.append((char) (i + 48)); return; } char[] cArr = new char[10]; int i5 = 0; while (i != 0) { cArr[i5] = (char) ((i % 10) + 48); i /= 10; i5++; } while (i5 < i2) { appendable.append('0'); i2--; } while (true) { i5--; if (i5 < 0) { return; } else { appendable.append(cArr[i5]); } } } }