package cn.jiguang.v; import android.util.Base64; import java.io.ByteArrayOutputStream; import java.io.Closeable; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.concurrent.ConcurrentHashMap; import java.util.zip.GZIPOutputStream; public class f { private static final Object a = new Object(); private static ConcurrentHashMap<String, ThreadLocal<SimpleDateFormat>> b = new ConcurrentHashMap<>(); /* access modifiers changed from: private */ public static class a extends ThreadLocal<SimpleDateFormat> { private String a; a(String str) { this.a = str; } /* access modifiers changed from: protected */ /* renamed from: a */ public SimpleDateFormat initialValue() { return new SimpleDateFormat(this.a, Locale.ENGLISH); } } public static String a(long j) { return a("yyyyMMdd HH:mm:ss.SSS").format(new Date(j)); } public static SimpleDateFormat a(String str) { ThreadLocal<SimpleDateFormat> threadLocal = b.get(str); if (threadLocal == null) { synchronized (a) { threadLocal = b.get(str); if (threadLocal == null) { threadLocal = new a(str); b.put(str, threadLocal); } } } return threadLocal.get(); } public static void a(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (Throwable unused) { } } } public static boolean a(long j, long j2) { if (j2 > 0) { return j <= 0 || System.currentTimeMillis() > j + j2; } throw new AssertionError(); } public static byte[] a(byte[] bArr) { Throwable th; GZIPOutputStream gZIPOutputStream; if (bArr == null || bArr.length == 0) { return bArr; } ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream); try { gZIPOutputStream.write(bArr); gZIPOutputStream.close(); byte[] byteArray = byteArrayOutputStream.toByteArray(); a(byteArrayOutputStream); a(gZIPOutputStream); return byteArray; } catch (Throwable th2) { th = th2; a(byteArrayOutputStream); a(gZIPOutputStream); throw th; } } catch (Throwable th3) { th = th3; gZIPOutputStream = null; a(byteArrayOutputStream); a(gZIPOutputStream); throw th; } } public static String b(String str) { return new String(Base64.decode(str.getBytes(), 2)); } public static String c(String str) { return Base64.encodeToString(str.getBytes(), 2); } }