无法解析Google Cookie过期日期

时间:2019-06-05 08:32:33

标签: java codenameone datetime-parsing

在某个时间点,网络线程在检索填满日志的google.com到期日期值(来自autoDetectAPN)方面一直失败。我检查了cookie中的值,它看起来像是“ fri,05-jul-2019 07:31:41 gmt”,实际上,这个值没有被解析。我做了一个快速测试(见下文)。您将不会看到com.codename1.io.ConnectionRequest:parseCookieHeader(String)尝试的任何格式都成功。有想法吗?

        String date = "fri, 05-jul-2019 07:31:41 gmt";

        String[] formats = new String[] {
        "EEE, dd-MMM-yyyy HH:mm:ss z",
        "EEE dd-MMM-yyyy HH:mm:ss z",
        "EEE, dd MMM yyyy HH:mm:ss z",
        "EEE dd MMM yyyy HH:mm:ss z",
        "EEE, dd-MMM-yyyy HH:mm:ss Z", 
        "EEE dd-MMM-yyyy HH:mm:ss Z",
        "EEE, dd MMM yyyy HH:mm:ss Z",
        "EEE dd MMM yyyy HH:mm:ss Z",
        "EEE, dd-MMM-yy HH:mm:ss z", 
        "EEE dd-MMM-yy HH:mm:ss z",
        "EEE, dd MMM yy HH:mm:ss z",
        "EEE dd MMM yy HH:mm:ss z",
        "EEE, dd-MMM-yy HH:mm:ss Z", 
        "EEE dd-MMM-yy HH:mm:ss Z",
        "EEE, dd MMM yy HH:mm:ss Z",
        "EEE dd MMM yy HH:mm:ss Z"
        };

        for (String format : formats) {
            try {
                com.codename1.l10n.SimpleDateFormat sdf = new com.codename1.l10n.SimpleDateFormat(format);
                System.out.println(date + " format: " + format + " => " + sdf.parse(date).getTime());
            } catch (Throwable t){
                System.out.println(date + " format: " + format + " => Nope");
            }
        }
``
And the result is:
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd-MMM-yyyy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd-MMM-yyyy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd MMM yyyy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd MMM yyyy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd-MMM-yyyy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd-MMM-yyyy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd MMM yyyy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd MMM yyyy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd-MMM-yy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd-MMM-yy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd MMM yy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd MMM yy HH:mm:ss z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd-MMM-yy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd-MMM-yy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE, dd MMM yy HH:mm:ss Z => Nope
    fri, 05-jul-2019 07:31:41 gmt format: EEE dd MMM yy HH:mm:ss Z => Nope

0 个答案:

没有答案