package com.google.gson.internal.sql;

import com.google.gson.d;
import com.google.gson.q;
import com.google.gson.u;
import com.google.gson.v;
import java.sql.Time;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import xk.b;
import xk.c;

/* loaded from: classes3.dex */
final class SqlTimeTypeAdapter extends u {

    /* renamed from: b, reason: collision with root package name */
    static final v f14986b = new v() { // from class: com.google.gson.internal.sql.SqlTimeTypeAdapter.1
        @Override // com.google.gson.v
        public u create(d dVar, com.google.gson.reflect.a aVar) {
            Class<Object> rawType = aVar.getRawType();
            if (rawType == Time.class) {
                return new SqlTimeTypeAdapter();
            }
            return null;
        }
    };

    /* renamed from: a, reason: collision with root package name */
    private final DateFormat f14987a;

    @Override // com.google.gson.u
    /* renamed from: a, reason: merged with bridge method [inline-methods] */
    public Time read(xk.a aVar) {
        Time time;
        if (aVar.L() == b.NULL) {
            aVar.G();
            return null;
        }
        String J = aVar.J();
        try {
            synchronized (this) {
                time = new Time(this.f14987a.parse(J).getTime());
            }
            return time;
        } catch (ParseException e10) {
            throw new q("Failed parsing '" + J + "' as SQL Time; at path " + aVar.m(), e10);
        }
    }

    @Override // com.google.gson.u
    /* renamed from: b, reason: merged with bridge method [inline-methods] */
    public void write(c cVar, Time time) {
        String format;
        if (time == null) {
            cVar.t();
            return;
        }
        synchronized (this) {
            format = this.f14987a.format((Date) time);
        }
        cVar.Q(format);
    }

    private SqlTimeTypeAdapter() {
        this.f14987a = new SimpleDateFormat("hh:mm:ss a");
    }
}
