Java Time to String timeToString(int s)

Here you can find the source of timeToString(int s)

Description

time To String

License

Open Source License

Declaration

public static String timeToString(int s) 

Method Source Code

//package com.java2s;
/*//from   ww w.java 2 s.  co m
* Argus Open Source
* Software to apply Statistical Disclosure Control techniques
* 
* Copyright 2014 Statistics Netherlands
* 
* This program is free software; you can redistribute it and/or 
* modify it under the terms of the European Union Public Licence 
* (EUPL) version 1.1, as published by the European Commission.
* 
* You can find the text of the EUPL v1.1 on
* https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
* 
* This software is distributed on an "AS IS" basis without 
* warranties or conditions of any kind, either express or implied.
*/

public class Main {
    public static String timeToString(int s) {
        String hs = "";
        int h = 0;
        int m = 0;
        if (s >= 3600) {
            h = s / 3600;
            hs = " " + h + " hrs";
            s = s - h * 3600;
        }
        if ((h > 0) || (s >= 60)) {
            m = s / 60;
            hs = hs + " " + m + " min";
            s = s - m * 60;
        }
        hs = hs + " " + s + " sec";
        return hs;
    }
}

Related

  1. timeToString(Date date)
  2. timeToString(double d)
  3. timeToString(double time, boolean longNames)
  4. timeToString(final Date date)
  5. timeToString(final long time)
  6. timeToString(int time)
  7. timeToString(int time)
  8. timeToString(int time)
  9. TimeToString(int time)