package org.bouncycastle.openpgp.api.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/* JADX INFO: loaded from: classes2.dex */
public class UTCUtil {
    public static String format(Date date) {
        return utc().format(date);
    }

    public static Date parse(String str) {
        try {
            return utc().parse(str);
        } catch (ParseException e) {
            throw new IllegalArgumentException("Malformed UTC timestamp: " + str, e);
        }
    }

    private static SimpleDateFormat utc() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        return simpleDateFormat;
    }
}
