package com.google.gson;

import a.b.c.a.a;
import a.e.a.t;
import a.e.a.y.c;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class DefaultDateTypeAdapter extends t<Date> {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Class<? extends Date> f5391a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final List<DateFormat> f5392b;

    /* JADX WARN: Code restructure failed: missing block: B:13:0x002b, code lost:
    
        r4 = a.e.a.w.y.d.a.b(r4, new java.text.ParsePosition(0));
     */
    @Override // a.e.a.t
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public java.util.Date a(a.e.a.y.a r4) throws java.io.IOException {
        /*
            r3 = this;
            a.e.a.y.b r0 = r4.Z()
            a.e.a.y.b r1 = a.e.a.y.b.NULL
            if (r0 != r1) goto Ld
            r4.V()
            r4 = 0
            goto L5a
        Ld:
            java.lang.String r4 = r4.X()
            java.util.List<java.text.DateFormat> r0 = r3.f5392b
            monitor-enter(r0)
            java.util.List<java.text.DateFormat> r1 = r3.f5392b     // Catch: java.lang.Throwable -> L68
            java.util.Iterator r1 = r1.iterator()     // Catch: java.lang.Throwable -> L68
        L1a:
            boolean r2 = r1.hasNext()     // Catch: java.lang.Throwable -> L68
            if (r2 == 0) goto L2b
            java.lang.Object r2 = r1.next()     // Catch: java.lang.Throwable -> L68
            java.text.DateFormat r2 = (java.text.DateFormat) r2     // Catch: java.lang.Throwable -> L68
            java.util.Date r4 = r2.parse(r4)     // Catch: java.text.ParseException -> L1a java.lang.Throwable -> L68
            goto L35
        L2b:
            java.text.ParsePosition r1 = new java.text.ParsePosition     // Catch: java.text.ParseException -> L61 java.lang.Throwable -> L68
            r2 = 0
            r1.<init>(r2)     // Catch: java.text.ParseException -> L61 java.lang.Throwable -> L68
            java.util.Date r4 = a.e.a.w.y.d.a.b(r4, r1)     // Catch: java.text.ParseException -> L61 java.lang.Throwable -> L68
        L35:
            monitor-exit(r0)     // Catch: java.lang.Throwable -> L68
            java.lang.Class<? extends java.util.Date> r0 = r3.f5391a
            java.lang.Class<java.util.Date> r1 = java.util.Date.class
            if (r0 != r1) goto L3d
            goto L5a
        L3d:
            java.lang.Class<java.sql.Timestamp> r1 = java.sql.Timestamp.class
            if (r0 != r1) goto L4c
            java.sql.Timestamp r0 = new java.sql.Timestamp
            long r1 = r4.getTime()
            r0.<init>(r1)
        L4a:
            r4 = r0
            goto L5a
        L4c:
            java.lang.Class<java.sql.Date> r1 = java.sql.Date.class
            if (r0 != r1) goto L5b
            java.sql.Date r0 = new java.sql.Date
            long r1 = r4.getTime()
            r0.<init>(r1)
            goto L4a
        L5a:
            return r4
        L5b:
            java.lang.AssertionError r4 = new java.lang.AssertionError
            r4.<init>()
            throw r4
        L61:
            r1 = move-exception
            a.e.a.r r2 = new a.e.a.r     // Catch: java.lang.Throwable -> L68
            r2.<init>(r4, r1)     // Catch: java.lang.Throwable -> L68
            throw r2     // Catch: java.lang.Throwable -> L68
        L68:
            r4 = move-exception
            monitor-exit(r0)     // Catch: java.lang.Throwable -> L68
            throw r4
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.gson.DefaultDateTypeAdapter.a(a.e.a.y.a):java.lang.Object");
    }

    @Override // a.e.a.t
    public void b(c cVar, Date date) throws IOException {
        Date date2 = date;
        if (date2 == null) {
            cVar.M();
            return;
        }
        synchronized (this.f5392b) {
            cVar.U(this.f5392b.get(0).format(date2));
        }
    }

    public String toString() {
        StringBuilder sbC;
        String simpleName;
        DateFormat dateFormat = this.f5392b.get(0);
        if (dateFormat instanceof SimpleDateFormat) {
            sbC = a.C("DefaultDateTypeAdapter(");
            simpleName = ((SimpleDateFormat) dateFormat).toPattern();
        } else {
            sbC = a.C("DefaultDateTypeAdapter(");
            simpleName = dateFormat.getClass().getSimpleName();
        }
        return a.t(sbC, simpleName, ')');
    }
}
