convert Second To Hour - Android java.util

Android examples for java.util:Second

Description

convert Second To Hour

Demo Code


//package com.java2s;

public class Main {

    public static String convertSecondToHour(String second) {
        String result = "";
        int secondInt;
        try {//www .jav  a2s .co  m
            secondInt = Integer.parseInt(second);
            int h = secondInt / 3600;
            int m = (secondInt - h * 3600) / 60;
            int s = secondInt % 60;
            result = String.format("%02d:%02d:%02d", h, m, s);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        return result;
    }
}

Related Tutorials