package ch;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import kotlin.jvm.internal.t;

/* loaded from: classes4.dex */
public final class k {

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

    private k() {
    }

    private final String a(Date date, String str, TimeZone timeZone) {
        Locale locale = Locale.US;
        t.f(locale, "Locale.US");
        String language = locale.getLanguage();
        t.f(locale, "Locale.US");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str, new Locale(language, locale.getCountry(), "POSIX"));
        if (timeZone != null) {
            simpleDateFormat.setTimeZone(timeZone);
        }
        return simpleDateFormat.format(date);
    }

    static /* synthetic */ String b(k kVar, Date date, String str, TimeZone timeZone, int i10, Object obj) {
        if ((i10 & 4) != 0) {
            timeZone = null;
        }
        return kVar.a(date, str, timeZone);
    }

    public static final String c(Date date) {
        t.g(date, "date");
        String b10 = b(f11968a, date, "yyyy-MM-dd'T'HH:mm:ssXX", null, 4, null);
        return b10 == null ? "" : b10;
    }

    public static /* synthetic */ String d(Date date, int i10, Object obj) {
        if ((i10 & 1) != 0) {
            date = new Date();
        }
        return c(date);
    }

    public static final String e(Date date) {
        t.g(date, "date");
        String a10 = f11968a.a(date, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("GMT"));
        return a10 == null ? "" : a10;
    }

    public static /* synthetic */ String f(Date date, int i10, Object obj) {
        if ((i10 & 1) != 0) {
            date = new Date();
        }
        return e(date);
    }

    public static final String g(long j10, TimeZone timeZone, Locale locale) {
        t.g(timeZone, "timeZone");
        t.g(locale, "locale");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", locale);
        simpleDateFormat.setTimeZone(timeZone);
        String format = simpleDateFormat.format(Long.valueOf(j10));
        t.f(format, "rfc2822formatter.format(epoch)");
        return format;
    }

    public static final long h() {
        return System.currentTimeMillis() / 1000;
    }

    public static final Date i(String str, TimeZone timeZone, Locale locale) {
        t.g(timeZone, "timeZone");
        t.g(locale, "locale");
        if (str == null) {
            return null;
        }
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", locale);
        simpleDateFormat.setTimeZone(timeZone);
        try {
            Date parse = simpleDateFormat.parse(str);
            return parse == null ? new Date() : parse;
        } catch (Exception unused) {
            return null;
        }
    }
}
