package nr;

import java.util.Calendar;
import java.util.GregorianCalendar;
import org.joda.time.DateTimeZone;
import org.joda.time.chrono.BuddhistChronology;
import org.joda.time.chrono.GJChronology;
import org.joda.time.chrono.GregorianChronology;
import org.joda.time.chrono.ISOChronology;
import org.joda.time.chrono.JulianChronology;

/* loaded from: classes5.dex */
final class b extends a implements g {

    /* renamed from: a, reason: collision with root package name */
    static final b f30369a = new b();

    protected b() {
    }

    @Override // nr.a, nr.g
    public long a(Object obj, org.joda.time.a aVar) {
        return ((Calendar) obj).getTime().getTime();
    }

    @Override // nr.a, nr.g
    public org.joda.time.a b(Object obj, org.joda.time.a aVar) {
        DateTimeZone k10;
        if (aVar != null) {
            return aVar;
        }
        Calendar calendar = (Calendar) obj;
        try {
            k10 = DateTimeZone.h(calendar.getTimeZone());
        } catch (IllegalArgumentException unused) {
            k10 = DateTimeZone.k();
        }
        return d(calendar, k10);
    }

    @Override // nr.c
    public Class c() {
        return Calendar.class;
    }

    public org.joda.time.a d(Object obj, DateTimeZone dateTimeZone) {
        if (obj.getClass().getName().endsWith(".BuddhistCalendar")) {
            return BuddhistChronology.T(dateTimeZone);
        }
        if (!(obj instanceof GregorianCalendar)) {
            return ISOChronology.U(dateTimeZone);
        }
        long time = ((GregorianCalendar) obj).getGregorianChange().getTime();
        return time == Long.MIN_VALUE ? GregorianChronology.L0(dateTimeZone) : time == Long.MAX_VALUE ? JulianChronology.M0(dateTimeZone) : GJChronology.X(dateTimeZone, time, 4);
    }
}
