Java Minute Get getMinutesTime(long msTime)

Here you can find the source of getMinutesTime(long msTime)

Description

Convert time in ms to 'mm minutes ss seconds' format

License

Apache License

Parameter

Parameter Description
msTime - time in millisecond

Return

- string for time or empty string for negative time

Declaration

public static synchronized String getMinutesTime(long msTime) 

Method Source Code

//package com.java2s;
/*/*from   w  w w.j  a  v  a 2  s .c  om*/
Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
    
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    
   http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    
See the License for the specific language governing permissions and
limitations under the License.
*/

public class Main {
    /**
     * Convert time in ms to 'mm minutes ss seconds' format
     * 
     * @param msTime - time in millisecond
     * @return - string for time or empty string for negative time
     */
    public static synchronized String getMinutesTime(long msTime) {
        if (msTime < 0) {
            return "";
        }
        long mm = msTime / (1000 * 60); //ms * s
        long tmp = msTime % (1000 * 60);
        long ss = tmp / 1000; //ms
        long ms = tmp % 1000;
        if (ms > 500) {
            ss++;
        }
        return "Total time: " + mm + " minutes " + ss + " seconds";
    }
}

Related

  1. getMinutesSeconds(long millisec, String fmt)
  2. getMinutesSinceEpoch()
  3. getMinutesString(long time)
  4. getMinuteStart(long ts)
  5. getMinutesText(long minutes)
  6. getNextMinute(Integer minute)
  7. getNumberOfMinutes(long milliseconds)
  8. getOffMinutes()
  9. getOffMinutes(long l)