- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
70 lines
2.4 KiB
Java
70 lines
2.4 KiB
Java
package com.amazonaws.util;
|
|
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.TimeZone;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class DateUtils {
|
|
public static final TimeZone GMT_TIMEZONE = TimeZone.getTimeZone("GMT");
|
|
public static final Map SDF_MAP = new HashMap();
|
|
|
|
public static ThreadLocal getSimpleDateFormat(final String str) {
|
|
Map map = SDF_MAP;
|
|
ThreadLocal<SimpleDateFormat> threadLocal = (ThreadLocal) map.get(str);
|
|
if (threadLocal == null) {
|
|
synchronized (map) {
|
|
try {
|
|
threadLocal = (ThreadLocal) map.get(str);
|
|
if (threadLocal == null) {
|
|
threadLocal = new ThreadLocal<SimpleDateFormat>() { // from class: com.amazonaws.util.DateUtils.1
|
|
@Override // java.lang.ThreadLocal
|
|
public SimpleDateFormat initialValue() {
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str, Locale.US);
|
|
simpleDateFormat.setTimeZone(DateUtils.GMT_TIMEZONE);
|
|
simpleDateFormat.setLenient(false);
|
|
return simpleDateFormat;
|
|
}
|
|
};
|
|
map.put(str, threadLocal);
|
|
}
|
|
} finally {
|
|
}
|
|
}
|
|
}
|
|
return threadLocal;
|
|
}
|
|
|
|
public static Date parse(String str, String str2) {
|
|
try {
|
|
return ((SimpleDateFormat) getSimpleDateFormat(str).get()).parse(str2);
|
|
} catch (ParseException e) {
|
|
throw new IllegalArgumentException(e);
|
|
}
|
|
}
|
|
|
|
public static String format(String str, Date date) {
|
|
return ((SimpleDateFormat) getSimpleDateFormat(str).get()).format(date);
|
|
}
|
|
|
|
public static Date parseISO8601Date(String str) {
|
|
try {
|
|
return parse("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", str);
|
|
} catch (IllegalArgumentException unused) {
|
|
return parse("yyyy-MM-dd'T'HH:mm:ss'Z'", str);
|
|
}
|
|
}
|
|
|
|
public static Date parseRFC822Date(String str) {
|
|
return parse("EEE, dd MMM yyyy HH:mm:ss z", str);
|
|
}
|
|
|
|
public static Date parseCompressedISO8601Date(String str) {
|
|
return parse("yyyyMMdd'T'HHmmss'Z'", str);
|
|
}
|
|
}
|