Java Second to Minute toMinutes(long millis)

Here you can find the source of toMinutes(long millis)

Description

to Minutes

License

Open Source License

Declaration

public static String toMinutes(long millis) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String toMinutes(long millis) {
        return toString(millis, "m");
    }/*  ww  w .  j a  va2  s  . co  m*/

    public static String toString(long millis, String unit) {
        double factor = getFactor(unit);
        return ((double) millis) / factor + unit;
    }

    private static long getFactor(String value) {
        long factor = 0;
        if (value.endsWith("ms")) {
            factor = 1;
        } else if (value.endsWith("s")) {
            factor = 1000;
        } else if (value.endsWith("m")) {
            factor = 1000 * 60;
        } else if (value.endsWith("h")) {
            factor = 1000 * 60 * 60;
        } else if (value.endsWith("d")) {
            factor = 1000 * 60 * 60 * 24;
        }
        return factor;
    }
}

Related

  1. toDecimal(long seconds, int nanoseconds)
  2. toDecimal(long seconds, int nanoseconds)
  3. toMinutes(int hour, int minutes)
  4. toMinutes(int s)
  5. toMinutes(long date)