zoukankan      html  css  js  c++  java
  • 一个小程序,时间util

    比较时间,如果此时间是今天的显示时间点,今天以前显日期

    public String getTime(Date time){
            
           SimpleDateFormat dateFormat1 = new SimpleDateFormat("MM-dd");
           SimpleDateFormat dateFormat2 = new SimpleDateFormat("HH:mm");
           SimpleDateFormat dateFormat3 = new SimpleDateFormat("yyyy-MM-dd");
           
           Date date = new Date();
           //获取当天的日期
           String dates=   dateFormat3.format(date);
            
              try {
                if( time.getTime()>dateFormat3.parse(dates).getTime()){
                      return dateFormat2.format(time);
                      
                  }else{
                      
                     return dateFormat1.format(time);
                  }
            } catch (ParseException e) {
                e.printStackTrace();
                return null;
            }
            
            
        }

  • 相关阅读:
    POJ 3280 Cheapest Palindrome
    POJ 1191 棋盘分割
    POJ 1260 Pearls
    HDOJ 4731 Minimum palindrome
    2013 ACM/ICPC Asia Regional Chengdu Online 1004 Minimum palindrome
    POJ 1836 Alignment
    POJ 3267 The Cow Lexicon
    POJ 1276 Cash Machine
    POJ 1837 Balance
    HDU 4554 叛逆的小明
  • 原文地址:https://www.cnblogs.com/zgghb/p/4633749.html
Copyright © 2011-2022 走看看