不可稀释的日期:“Fri Oct 10 23:11:07 IST 2014” (偏移20) [英] Unparseable date: "Fri Oct 10 23:11:07 IST 2014" (at offset 20)

查看:166
本文介绍了不可稀释的日期:“Fri Oct 10 23:11:07 IST 2014” (偏移20)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了这个功能来解析日期,但是这是例外:不可稀释的日期:Fri Oct 10 23:11:07 IST 2014(在偏移20)。请帮忙,因为我无法弄明白这个代码有什么问题。

I have created this funtion to parse date but this gives exception : Unparseable date: "Fri Oct 10 23:11:07 IST 2014" (at offset 20) . Please help as I am not able to figure out whats wrong with this code.

public Date parseDate() {
    String strDate ="Fri Oct 10 23:11:29 IST 2014";
    String newPattern = "EEE MMM dd HH:mm:ss Z yyyy";
    SimpleDateFormat formatter = new SimpleDateFormat(newPattern);
    try {
        Date date = formatter.parse(strDate);
        return date;
    } catch (java.text.ParseException e) {
        e.printStackTrace();
    }
    return null;
}


推荐答案

 SimpleDateFormat formatter = new SimpleDateFormat(newPattern);
 formatter.setLenient(true);

//将格式化程序设置为宽松解决问题

//setting the formatter to be lenient solves the problem

感谢各位的帮助....

Thanks folks for helping....

这篇关于不可稀释的日期:“Fri Oct 10 23:11:07 IST 2014” (偏移20)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆