Here you can find the source of getFormattedDuration(long fromTime)
public static String getFormattedDuration(long fromTime)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006-2007, Cloudsmith Inc. * The code, documentation and other materials contained herein have been * licensed under the Eclipse Public License - v 1.0 by the copyright holder * listed above, as the Initial Contributor under such license. The text of * such license is available at www.eclipse.org. ******************************************************************************/ import java.text.MessageFormat; public class Main { private static final MessageFormat TIME_FORMAT = new MessageFormat("{0}{1}"); private static final int MS_IN_SECOND = 1000; private static final int SEC_IN_MINUTE = 60; public static String getFormattedDuration(long fromTime) { long milliseconds = getDuration(fromTime); long seconds = milliseconds / MS_IN_SECOND; long minutes = seconds / SEC_IN_MINUTE; Object[] args = { Long.valueOf(minutes), Long.valueOf(seconds % SEC_IN_MINUTE) }; return TIME_FORMAT.format(args); }//from w w w .j a v a 2 s . c o m public static long getDuration(long fromTime) { return System.currentTimeMillis() - fromTime; } }