source: tmcsimulator/trunk/src/tmcsim/common/TimeUtils.java @ 349

Revision 349, 984 bytes checked in by jdalbey, 7 years ago (diff)

tmcsim.common package: Added class TimeUtils?.java and moved longtotime() into it from SimulationManagerView?.

Line 
1
2package tmcsim.common;
3
4/**
5 * A Utility class of methods for manipulating time values.
6 */
7public class TimeUtils
8{
9    /**
10     * Converts a the long representation of the time, to the H:MM:SS String format
11     *
12     * @param seconds number of seconds.
13     * @return String H:MM:SS time representation.
14     */
15    public static String longToTime(long seconds) {
16        String time = new String();     
17        long timeSegment;   
18       
19        timeSegment = seconds / 3600;
20        time += String.valueOf(timeSegment) + ":";     
21       
22        seconds = seconds % 3600;
23       
24        timeSegment = seconds / 60;
25        if(timeSegment < 10)
26            time += "0";
27       
28        time += String.valueOf(timeSegment) + ":";     
29        seconds = seconds % 60; 
30       
31        timeSegment = seconds;
32        if(timeSegment < 10)
33            time += "0";
34       
35        time += String.valueOf(timeSegment);
36       
37        return time;       
38    }
39
40   
41}
Note: See TracBrowser for help on using the repository browser.