Java Time Readable Format toTime(int duration)

Here you can find the source of toTime(int duration)

Description

to Time

License

Open Source License

Declaration

private static String toTime(int duration) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (C) 2014 Travis Ralston (turt2live)
 *
 * This software is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/

public class Main {
    private static String toTime(int duration) {
        double asMinutes = ((double) duration) / 60.0;
        int minutes = (int) Math.floor(asMinutes);
        int seconds = duration - (minutes * 60);
        return minutes + ":" + ((seconds + "").length() < 2 ? "0" + seconds : seconds);
    }//from  w w  w . j a v a2 s.  c om
}

Related

  1. getMaxTimeByStringDate(String date)
  2. humanTime(long ms)
  3. humanTime(long seconds)
  4. humanTime(long start, long end)
  5. toHumanable(long time_millsecod)
  6. toTime(long ms)
  7. toTime(long nanos)
  8. toTime(long time)
  9. toTime2(int value, int nanos, int meta)