zoukankan      html  css  js  c++  java
  • DateUtil(比较两个日期是否是同一天)

    1、比较两个日期是否是同一天

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    
    Date lastRecordTimeD = sdf.parse(lines[2]);
    
    Calendar lastRecordTimeCal = new GregorianCalendar();
    
    lastRecordTimeCal.setTime(lastRecordTimeD);
    
    Calendar nowTime = Calendar.getInstance();
    
    Calendar tempDate = (Calendar) nowTime.clone();
    
    tempDate.set(Calendar.YEAR, lastRecordTimeCal.get(Calendar.YEAR));
    tempDate.set(Calendar.MONTH, lastRecordTimeCal.get(Calendar.MONTH));
    tempDate.set(Calendar.DAY_OF_MONTH,lastRecordTimeCal.get(Calendar.DAY_OF_MONTH));
    
    //是否是同一天
    boolean sameDay = false;
    
    if (nowTime.equals(tempDate)) {
        sameDay = true;
    }
    这个博客主要是javaEE相关或者不相关的记录, hadoop与spark的相关文章我写在下面地址的博客啦~ http://www.cnblogs.com/sorco
  • 相关阅读:
    C#_Assembly-Reflection_程序集与反射
    C#_event_事件
    C#_扩展方法
    C#_Delegate_泛型
    C#_正则表达式
    C#_序列化
    Unity_ClickToShow_FadeInAndOut
    RecordToday
    写作技巧
    高效休息法
  • 原文地址:https://www.cnblogs.com/orco/p/6223183.html
Copyright © 2011-2022 走看看