package z4; import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseException; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Locale; /* loaded from: classes2.dex */ final class a extends q { /* renamed from: a, reason: collision with root package name */ private final Class f15809a; /* renamed from: b, reason: collision with root package name */ private final List f15810b; a(Class cls, String str) { ArrayList arrayList = new ArrayList(); this.f15810b = arrayList; this.f15809a = g(cls); Locale locale = Locale.US; arrayList.add(new SimpleDateFormat(str, locale)); if (Locale.getDefault().equals(locale)) { return; } arrayList.add(new SimpleDateFormat(str)); } private Date e(String str) { synchronized (this.f15810b) { Iterator it = this.f15810b.iterator(); while (it.hasNext()) { try { return ((DateFormat) it.next()).parse(str); } catch (ParseException unused) { } } try { return d5.a.c(str, new ParsePosition(0)); } catch (ParseException e10) { throw new o(str, e10); } } } private static Class g(Class cls) { if (cls == Date.class || cls == java.sql.Date.class || cls == Timestamp.class) { return cls; } throw new IllegalArgumentException("Date type must be one of " + Date.class + ", " + Timestamp.class + ", or " + java.sql.Date.class + " but was " + cls); } @Override // z4.q /* renamed from: f, reason: merged with bridge method [inline-methods] */ public Date b(g5.a aVar) { if (aVar.F0() == g5.b.NULL) { aVar.w0(); return null; } Date e10 = e(aVar.D0()); Class cls = this.f15809a; if (cls == Date.class) { return e10; } if (cls == Timestamp.class) { return new Timestamp(e10.getTime()); } if (cls == java.sql.Date.class) { return new java.sql.Date(e10.getTime()); } throw new AssertionError(); } @Override // z4.q /* renamed from: h, reason: merged with bridge method [inline-methods] */ public void d(g5.c cVar, Date date) { if (date == null) { cVar.j0(); return; } synchronized (this.f15810b) { cVar.I0(((DateFormat) this.f15810b.get(0)).format(date)); } } public String toString() { DateFormat dateFormat = (DateFormat) this.f15810b.get(0); if (dateFormat instanceof SimpleDateFormat) { return "DefaultDateTypeAdapter(" + ((SimpleDateFormat) dateFormat).toPattern() + ')'; } return "DefaultDateTypeAdapter(" + dateFormat.getClass().getSimpleName() + ')'; } public a(Class cls, int i10, int i11) { ArrayList arrayList = new ArrayList(); this.f15810b = arrayList; this.f15809a = g(cls); Locale locale = Locale.US; arrayList.add(DateFormat.getDateTimeInstance(i10, i11, locale)); if (!Locale.getDefault().equals(locale)) { arrayList.add(DateFormat.getDateTimeInstance(i10, i11)); } if (b5.e.e()) { arrayList.add(b5.j.c(i10, i11)); } } }