首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Java如何进行日历比较

Java如何进行日历比较
EN

Stack Overflow用户
提问于 2018-10-12 19:39:48
回答 2查看 69关注 0票数 -1

我从一个文本中获取开始日期,并存储在一个字符串变量中。我想将开始日期与当前日期进行比较,即开始日期是否早于当前日期。

public static void main(String[] rags) throws ParseException{
    String total= "I am Going to join in scholl at 21/10/2108";
    String[] effectiveDateText=total.split(" ");
    String effectiveDate=effectiveDateText[effectiveDateText.length-1];
    System.out.println(effectiveDate);
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    Calendar today = Calendar.getInstance();
    String todate=sdf.format(today.getTime());
    System.out.println(todate);
    if(effectiveDate<todate){
        System.out.println("effective date is less then the previous date");
    }
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52778751

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档