Add timezones to preference page
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / widgets / Utils.java
index 298967c090c2c81117cd049b622b121f332f478e..78f8ba7a6170038373180de5fa79fd50a73efd54 100644 (file)
@@ -6,10 +6,11 @@
  * http://www.eclipse.org/legal/epl-v10.html
  *
  * Contributors:
- *   Intel Corporation - Initial API and implementation
- *   Ruslan A. Scherbakov, Intel - Initial API and implementation
- *   Alvaro Sanchez-Leon - Udpated for TMF
- *   Patrick Tasse - Refactoring
+ *     Intel Corporation - Initial API and implementation
+ *     Ruslan A. Scherbakov, Intel - Initial API and implementation
+ *     Alvaro Sanchez-Leon - Udpated for TMF
+ *     Patrick Tasse - Refactoring
+ *     Marc-Andre Laperle - Add time zone preference
  *****************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
@@ -18,7 +19,9 @@ import java.text.NumberFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.TimeZone;
 
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimePreferences;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
 import org.eclipse.swt.graphics.Color;
@@ -80,6 +83,17 @@ public class Utils {
     private static final long SEC_IN_NS = 1000000000;
     private static final long MILLISEC_IN_NS = 1000000;
 
+    /**
+     * Update the time and date formats to use the current time zone
+     *
+     * @since 2.1
+     */
+    public static void updateTimeZone() {
+        TimeZone timeZone = TmfTimePreferences.getInstance().getTimeZone();
+        TIME_FORMAT.setTimeZone(timeZone);
+        DATE_FORMAT.setTimeZone(timeZone);
+    }
+
     static Rectangle clone(Rectangle source) {
         return new Rectangle(source.x, source.y, source.width, source.height);
     }
This page took 0.025533 seconds and 5 git commands to generate.