changeset 48:d1ad84f404e5

Show human-readable start/stop times, only show stop time for stopped vms
author Jon VanAlten <jon.vanalten@redhat.com>
date Wed, 18 Jan 2012 10:16:56 -0500
parents f0f6c2e90f50
children fae2136d8e21
files src/com/redhat/thermostat/client/strings.properties src/com/redhat/thermostat/client/ui/VmPanel.java
diffstat 2 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/redhat/thermostat/client/strings.properties	Tue Jan 17 18:02:44 2012 -0500
+++ b/src/com/redhat/thermostat/client/strings.properties	Wed Jan 18 10:16:56 2012 -0500
@@ -106,6 +106,7 @@
 VM_INFO_PROCESS_ID = Process Id
 VM_INFO_START_TIME = Start time
 VM_INFO_STOP_TIME = Stop time
+VM_INFO_RUNNING = Running
 VM_INFO_MAIN_CLASS = Main Class
 VM_INFO_COMMAND_LINE = Command Line
 VM_INFO_JAVA_VERSION = Java Version
--- a/src/com/redhat/thermostat/client/ui/VmPanel.java	Tue Jan 17 18:02:44 2012 -0500
+++ b/src/com/redhat/thermostat/client/ui/VmPanel.java	Wed Jan 18 10:16:56 2012 -0500
@@ -6,7 +6,11 @@
 import java.awt.Component;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
+import java.text.DateFormat;
 import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
 import java.util.List;
 
 import javax.swing.JPanel;
@@ -72,9 +76,17 @@
 
         entry = new TableEntry(_("VM_INFO_PROCESS_ID"), String.valueOf(vmInfo.getVmPid()));
         processSection.add(entry);
-        entry = new TableEntry(_("VM_INFO_START_TIME"), String.valueOf(vmInfo.getStartTimeStamp()));
+        long startTime = vmInfo.getStartTimeStamp();
+        DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL);
+        entry = new TableEntry(_("VM_INFO_START_TIME"), df.format(new Date(startTime)));
         processSection.add(entry);
-        entry = new TableEntry(_("VM_INFO_STOP_TIME"), String.valueOf(vmInfo.getStopTimeStamp()));
+        long stopTime = vmInfo.getStopTimeStamp();
+        if (stopTime >= startTime) {
+            // Only show a stop time if we have actually stopped.
+            entry = new TableEntry(_("VM_INFO_STOP_TIME"), df.format(new Date(stopTime)));
+        } else {
+            entry = new TableEntry(_("VM_INFO_STOP_TIME"), _("VM_INFO_RUNNING"));
+        }
         processSection.add(entry);
 
         Section javaSection = new Section(_("VM_INFO_SECTION_JAVA"));