Twitter date unparseable?

后端 未结 7 2035
误落风尘
误落风尘 2020-12-11 15:52

I want to convert the date string in a Twitter response to a Date object, but I always get a ParseException and I cannot see the error!?!

Input string: Thu Dec 23 18

7条回答
  •  [愿得一人]
    2020-12-11 16:07

    This works for me ;)

    public static Date getTwitterDate(String date) throws ParseException
    {
        final String TWITTER = "EEE, dd MMM yyyy HH:mm:ss Z";
        SimpleDateFormat sf = new SimpleDateFormat(TWITTER, Locale.ENGLISH);
        sf.setLenient(true);
        return sf.parse(date);
    }
    

提交回复
热议问题