what-the-bank/sources/com/facetec/sdk/dr.java

123 lines
3.8 KiB
Java

package com.facetec.sdk;
import java.io.IOException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
/* loaded from: classes.dex */
final class dr extends ek<Date> {
private final Class<? extends Date> a;
private final List<DateFormat> b;
@Override // com.facetec.sdk.ek
public final /* synthetic */ void b(ga gaVar, Date date) throws IOException {
Date date2 = date;
if (date2 == null) {
gaVar.h();
return;
}
synchronized (this.b) {
gaVar.b(this.b.get(0).format(date2));
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public dr(Class<? extends Date> cls, String str) {
ArrayList arrayList = new ArrayList();
this.b = arrayList;
this.a = b(cls);
arrayList.add(new SimpleDateFormat(str, Locale.US));
if (Locale.getDefault().equals(Locale.US)) {
return;
}
arrayList.add(new SimpleDateFormat(str));
}
public dr(Class<? extends Date> cls, int i, int i2) {
ArrayList arrayList = new ArrayList();
this.b = arrayList;
this.a = b(cls);
arrayList.add(DateFormat.getDateTimeInstance(i, i2, Locale.US));
if (!Locale.getDefault().equals(Locale.US)) {
arrayList.add(DateFormat.getDateTimeInstance(i, i2));
}
if (ew.b()) {
arrayList.add(fa.e(i, i2));
}
}
private static Class<? extends Date> b(Class<? extends Date> cls) {
if (cls == Date.class || cls == java.sql.Date.class || cls == Timestamp.class) {
return cls;
}
StringBuilder sb = new StringBuilder("Date type must be one of ");
sb.append(Date.class);
sb.append(", ");
sb.append(Timestamp.class);
sb.append(", or ");
sb.append(java.sql.Date.class);
sb.append(" but was ");
sb.append(cls);
throw new IllegalArgumentException(sb.toString());
}
private Date c(String str) {
synchronized (this.b) {
Iterator<DateFormat> it = this.b.iterator();
while (it.hasNext()) {
try {
return it.next().parse(str);
} catch (ParseException unused) {
}
}
try {
return fp.a(str, new ParsePosition(0));
} catch (ParseException e) {
throw new ei(str, e);
}
}
}
public final String toString() {
DateFormat dateFormat = this.b.get(0);
if (dateFormat instanceof SimpleDateFormat) {
StringBuilder sb = new StringBuilder("DefaultDateTypeAdapter(");
sb.append(((SimpleDateFormat) dateFormat).toPattern());
sb.append(')');
return sb.toString();
}
StringBuilder sb2 = new StringBuilder("DefaultDateTypeAdapter(");
sb2.append(dateFormat.getClass().getSimpleName());
sb2.append(')');
return sb2.toString();
}
@Override // com.facetec.sdk.ek
public final /* synthetic */ Date a(fu fuVar) throws IOException {
if (fuVar.i() == gc.NULL) {
fuVar.l();
return null;
}
Date c = c(fuVar.h());
Class<? extends Date> cls = this.a;
if (cls == Date.class) {
return c;
}
if (cls == Timestamp.class) {
return new Timestamp(c.getTime());
}
if (cls == java.sql.Date.class) {
return new java.sql.Date(c.getTime());
}
throw new AssertionError();
}
}