Java 将秒转化为xx分xx秒

代码

 private static String getMinutes(int seconds){
        if(seconds>0){
            int remainder = seconds % 60;
            int minutes = (seconds - remainder) / 60;
            String minute = String.valueOf(minutes).length()<2 ? "0"+minutes : String.valueOf(minutes);
            String second = String.valueOf(remainder).length()<2 ? "0"+remainder : String.valueOf(remainder);
            return minute+":"+second;
        }
        return "00:00";
    }
posted @ 2023-07-03 17:12  freedomlog  阅读(52)  评论(0编辑  收藏  举报