Java Time Format formatPeroid(long time)

Here you can find the source of formatPeroid(long time)

Description

format Peroid

License

Apache License

Declaration

public static String formatPeroid(long time) 

Method Source Code

//package com.java2s;
/**//from  ww w . j ava2 s . c om
   Copyright [Shan Yin]
    
   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 {
    public static String formatPeroid(long time) {
        long seconds = time / 1000;

        long s = seconds % 60;
        long m = (seconds / 60) % 60;
        long h = seconds / 60 / 60;

        return String.format("%02d:%02d:%02d", h, m, s);
    }
}

Related

  1. formatMicroSpan(long time)
  2. formatMili(long timeDelta)
  3. formatMs(long elapsedTime)
  4. formatMusicTime(int time)
  5. formatNanosec(long timeNanosec)
  6. formatRemainingTime(float seccounds)
  7. formatRuntime(long runtime)
  8. formatRuntime(long time, boolean fixedlength)
  9. formatSample(final int aValue, final long aTimestamp)