获取与SimpleDateFormat的日期/时间 [英] Get date/time with SimpleDateFormat

查看:178
本文介绍了获取与SimpleDateFormat的日期/时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

乡亲! 我有这样的日期条目:

folks! I've got such date entry:

<pubDate>23/06/2011 11:57</pubDate>

我尝试分析它:

I try to parse it:

mDateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm");
item_tag.getChild("pubDate").setEndTextElementListener(new EndTextElementListener() {

            @Override
            public void end(String body) {
                date= new GregorianCalendar(0,0,0).getTime();
                try {
                    date=mDateFormat.parse(body);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
        });

但我得到类似的东西: 23/57/2011 11:57 我得到分钟,而不是月份值 有什么毛病我的code?

But I get something like that: 23/57/2011 11:57 I get minutes instead of month value What's wrong with my code?

推荐答案

您code看起来不错。看看你有什么真正传递给该方法,或者只是检查,如果你喜欢插入线会发生什么:

Your code looks OK. Check out what do you really pass to this method, or just check what will happen if you insert line like:

body = "23/06/2011 11:57";

这篇关于获取与SimpleDateFormat的日期/时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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