zoukankan      html  css  js  c++  java
  • Android 时钟(由秒转变为时分秒)

    int second = 0;
    Handler handler = new Handler();
            handler.post(runnable);
    
    Runnable runnable = new Runnable() {
            @Override
            public void run() {
                second++;
                patrol_time_txt.setText(Util.getTime(second));
                handler.postDelayed(runnable, 1000);
            }
        };
    //根据秒数转化为时分秒   00:00:00
    public
    static String getTime(int second) { if (second < 10) { return "00:0" + second; } if (second < 60) { return "00:" + second; } if (second < 3600) { int minute = second / 60; second = second - minute * 60; if (minute < 10) { if (second < 10) { return "0" + minute + ":0" + second; } return "0" + minute + ":" + second; } if (second < 10) { return minute + ":0" + second; } return minute + ":" + second; } int hour = second / 3600; int minute = (second - hour * 3600) / 60; second = second - hour * 3600 - minute * 60; if (hour < 10) { if (minute < 10) { if (second < 10) { return "0" + hour + ":0" + minute + ":0" + second; } return "0" + hour + ":0" + minute + ":" + second; } if (second < 10) { return "0" + hour + minute + ":0" + second; } return "0" + hour + minute + ":" + second; } if (minute < 10) { if (second < 10) { return hour + ":0" + minute + ":0" + second; } return hour + ":0" + minute + ":" + second; } if (second < 10) { return hour + minute + ":0" + second; } return hour + minute + ":" + second; }
  • 相关阅读:
    搭建consul cluster(三节点)
    php设计模式之:装饰者模式
    php设计模式之:中介者模式
    PECL 和 PEAR
    firefox汉化(利用中文插件)
    数据结构之最小树生成(用php描述)
    php设计模式之:观察者模式
    Ubuntu安装Microsoft Windows Fonts微软字体库
    mysql事物处理
    php数字转中文
  • 原文地址:https://www.cnblogs.com/lsc183/p/6949757.html
Copyright © 2011-2022 走看看