Here you can find the source of formatTime(long timeInSecond)
public static String formatTime(long timeInSecond)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Australian Nuclear Science and Technology Organisation. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w w w. jav a 2 s .c o m*/ * Bragg Institute - initial API and implementation ******************************************************************************/ public class Main { public static String formatTime(long timeInSecond) { long hour = timeInSecond / (60 * 60); long minute = (timeInSecond - (hour * 60 * 60)) / 60; long second = timeInSecond % 60; StringBuilder builder = new StringBuilder(); if (hour < 10) { builder.append("0" + hour); } else { builder.append(hour); } builder.append(":"); if (minute < 10) { builder.append("0" + minute); } else { builder.append(minute); } builder.append(":"); if (second < 10) { builder.append("0" + second); } else { builder.append(second); } return builder.toString(); } }