两个字符串日期与简单日期格式(例如EE,MMM dd yyyy)进行比较 [英] two string date compare with simple dateformat like EE,MMM dd yyyy

查看:411
本文介绍了两个字符串日期与简单日期格式(例如EE,MMM dd yyyy)进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将两个字符串日期与SimpleDateformat进行比较,例如EE,MMM dd yyyy
,但是当我进行比较时,它将仅对第一个值 EE进行验证,而其他月份,日期和年份仅在有人知道这一点时才进行验证问题解决方案,请帮助我解决,并在此先感谢所有人

i need to compare two string dates with SimpleDateformat like EE,MMM dd yyyy but when i compare it it will validate only the first value "EE" only other month,date and year not validating if anyone know this problem solution please help me to solve and thanks in advance to all

推荐答案

 SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy"/*or whatever your format is*/, Locale.US);
        try {
            Date actualDate = format.parse(actualDate);
            Date dateToCompare = format.parse(dateToCompare);

           if (actualDate.after(dateToCompare) || actualDate.before(dateToCompare)) {
                // Toast.makeText(context,""+actualDate.toString(),Toast.LENGTH_LONG).show();

            }
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

将其与日期格式进行比较,然后使用String结果。

Compare it with date format and then use the String result.

这篇关于两个字符串日期与简单日期格式(例如EE,MMM dd yyyy)进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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