将秒数转换为基于00:00的时间

/**
     * 将秒数转换为基于00:00的时间
     * 如541=9*60+1,表示09:01
     * @param minutes
     * @return
     */
    public static String getTimeByMinutes(int minutes){
        //处理小时
        int hour = minutes / 60;
        String hourTime = "";
        if(hour >= 0 && hour < 10){
            hourTime = "0" + hour;// 1 --> 01
        }else if(hour >= 10 && hour < 24){
            hourTime = "" + hour;
        }else if(hour >= 24){
            hourTime = "0" + (hour-24);
        }
        //处理分钟
        int min = minutes % 60;
        String minTime = "";
        if(min >= 0 && min < 10){
            minTime = "0" + min;// 1 --> 01
        }else{
            minTime = "" + min;
        }
        
        return hourTime + ":" + minTime;
    }

 

posted @ 2016-05-16 10:13  艺言弈行  阅读(955)  评论(0编辑  收藏  举报