diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/Activator.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/Activator.java
index 65ada5aea9..6af0a7030d 100644
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/Activator.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/Activator.java
@@ -20,14 +20,15 @@ package com.raytheon.uf.viz.collaboration.ui;
* further licensing information.
**/
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.osgi.framework.BundleContext;
+import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
+import com.raytheon.uf.common.status.UFStatus.Priority;
+import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore;
/**
* The activator class controls the plug-in life cycle
@@ -38,7 +39,8 @@ import com.raytheon.uf.common.status.UFStatus;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Mar 1, 2012 rferrel Initial creation
+ * Mar 1, 2012 rferrel Initial creation
+ * Feb 19, 2014 2631 mpduff Changed to use the HierarchicalPreferenceStore.
*
*
*
@@ -56,7 +58,7 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
- private ScopedPreferenceStore prefs;
+ private IPersistentPreferenceStore prefs;
/**
* The constructor
@@ -71,6 +73,7 @@ public class Activator extends AbstractUIPlugin {
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
+ @Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
@@ -83,6 +86,7 @@ public class Activator extends AbstractUIPlugin {
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
* )
*/
+ @Override
public void stop(BundleContext context) throws Exception {
plugin = null;
if (this.prefs != null) {
@@ -102,8 +106,15 @@ public class Activator extends AbstractUIPlugin {
@Override
public IPersistentPreferenceStore getPreferenceStore() {
- if (prefs == null) {
- prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, PLUGIN_ID);
+ try {
+ if (prefs == null) {
+ prefs = new HierarchicalPreferenceStore(this);
+ }
+ } catch (LocalizationException e) {
+ UFStatus.getHandler().handle(
+ Priority.PROBLEM,
+ "Error reading preference store: "
+ + e.getLocalizedMessage(), e);
}
return prefs;
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefConstants.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefConstants.java
index 3cf2168a2d..7f1440a33c 100644
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefConstants.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollabPrefConstants.java
@@ -19,7 +19,6 @@
**/
package com.raytheon.uf.viz.collaboration.ui.prefs;
-
/**
* Collaboration preferences constants used to interact with preference store
*
@@ -33,6 +32,7 @@ package com.raytheon.uf.viz.collaboration.ui.prefs;
* Jan 14, 2014 2630 bclement added away on idle constants
* Jan 27, 2014 2700 bclement added auto accept subscribe
* Feb 3, 2014 2699 bclement added handle preferences
+ * Feb 18, 2014 2631 mpduff Add constants for room change events.
*
*
*
@@ -63,6 +63,15 @@ public class CollabPrefConstants {
public static final int AWAY_TIMEOUT_DEFAULT = 10; // ten minutes
+ /** Enable join events field editor id */
+ public static final String ENABLE_JOIN_EVENTS_FIELD_EDITOR_ID = "enableJoinAlerts";
+
+ /** Join file field editor id */
+ public static final String JOIN_FILE_FIELD_EDITOR_ID = "roomJoinSoundFile";
+
+ /** Include nws feed field editor id */
+ public static final String INCLUDE_NWS_FEED_FIELD_EDITOR_ID = "includeNwsFeed";
+
public class HttpCollaborationConfiguration {
public static final String P_SESSION_CONFIGURED = "http.sessionConfigured";
@@ -71,8 +80,7 @@ public class CollabPrefConstants {
public static enum HandleOption {
BLANK("Blank"), USERNAME("User Name"), FULLNAME("Full Name"), ROLE(
- "Role"), CUSTOM(
- "Custom");
+ "Role"), CUSTOM("Custom");
public final String display;
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationRoomChangePreferencePage.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationRoomChangePreferencePage.java
new file mode 100644
index 0000000000..57f49a6602
--- /dev/null
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/prefs/CollaborationRoomChangePreferencePage.java
@@ -0,0 +1,141 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.uf.viz.collaboration.ui.prefs;
+
+import java.io.File;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.FileFieldEditor;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import com.raytheon.uf.common.localization.LocalizationContext;
+import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
+import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
+import com.raytheon.uf.common.localization.LocalizationFile;
+import com.raytheon.uf.common.localization.PathManager;
+import com.raytheon.uf.common.localization.PathManagerFactory;
+import com.raytheon.uf.viz.collaboration.ui.Activator;
+
+/**
+ * Collaboration's Room Events preferences page.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 18, 2014 2631 mpduff Initial creation.
+ *
+ *
+ *
+ * @author mpduff
+ * @version 1.0
+ */
+
+public class CollaborationRoomChangePreferencePage extends
+ FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+ /** Include nws-collaboration feed controls */
+ private BooleanFieldEditor includeFeed;
+
+ /** Join event controls */
+ private FileFieldEditor joinFileEditor;
+
+ /** Enable join alerts controls */
+ private BooleanFieldEditor enableJoinAlerts;
+
+ /**
+ * Constructor.
+ */
+ public CollaborationRoomChangePreferencePage() {
+ super(GRID);
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ }
+
+ @Override
+ protected void createFieldEditors() {
+ enableJoinAlerts = new BooleanFieldEditor(
+ CollabPrefConstants.ENABLE_JOIN_EVENTS_FIELD_EDITOR_ID,
+ "Enable Join Room Alerts", BooleanFieldEditor.DEFAULT,
+ getFieldEditorParent());
+ this.addField(enableJoinAlerts);
+
+ joinFileEditor = new FileFieldEditor(
+ CollabPrefConstants.JOIN_FILE_FIELD_EDITOR_ID, "Sound File",
+ getFieldEditorParent());
+
+ PathManager manager = (PathManager) PathManagerFactory.getPathManager();
+ LocalizationContext context = manager.getContext(
+ LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
+ LocalizationFile file = manager.getLocalizationFile(context,
+ "collaboration" + File.separator + "sounds" + File.separator);
+ if (!file.exists()) {
+ file.getFile().mkdirs();
+ }
+ joinFileEditor.setFilterPath(file.getFile());
+ this.addField(joinFileEditor);
+
+ // Apply to nws collaboration feed if checked
+ includeFeed = new BooleanFieldEditor(
+ CollabPrefConstants.INCLUDE_NWS_FEED_FIELD_EDITOR_ID,
+ "Apply to NWS-collaboration feed", BooleanFieldEditor.DEFAULT,
+ getFieldEditorParent());
+ this.addField(includeFeed);
+
+ boolean enabled = this.getPreferenceStore().getBoolean(
+ CollabPrefConstants.ENABLE_JOIN_EVENTS_FIELD_EDITOR_ID);
+ joinFileEditor.setEnabled(enabled, getFieldEditorParent());
+ includeFeed.setEnabled(enabled, getFieldEditorParent());
+
+ if (!joinFileEditor.isValid()) {
+ joinFileEditor.setStringValue("");
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.preference.FieldEditorPreferencePage#propertyChange
+ * (org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getSource().equals(this.enableJoinAlerts)) {
+ boolean enabled = (Boolean) event.getNewValue();
+ joinFileEditor.setEnabled(enabled, getFieldEditorParent());
+ includeFeed.setEnabled(enabled, getFieldEditorParent());
+ } else if (event.getSource().equals(this.joinFileEditor)) {
+ if (enableJoinAlerts.getBooleanValue()) {
+ super.propertyChange(event);
+ }
+ } else {
+ super.propertyChange(event);
+ }
+ }
+}
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java
index f83d5e3c05..12ba61395a 100644
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/AbstractSessionView.java
@@ -67,6 +67,7 @@ import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
+import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.collaboration.comm.identity.IMessage;
import com.raytheon.uf.viz.collaboration.comm.identity.user.IUser;
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
@@ -78,6 +79,7 @@ import com.raytheon.uf.viz.collaboration.ui.actions.CutTextAction;
import com.raytheon.uf.viz.collaboration.ui.actions.PasteTextAction;
import com.raytheon.uf.viz.collaboration.ui.actions.PopupNotifier;
import com.raytheon.uf.viz.collaboration.ui.data.AlertWord;
+import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.icon.IconUtil;
import com.raytheon.viz.ui.views.CaveFloatingView;
@@ -96,6 +98,7 @@ import com.raytheon.viz.ui.views.CaveFloatingView;
* Dec 19, 2013 2563 bclement moved color lookup into runAsync block
* Jan 30, 2014 2698 bclement get display name from child class
* Feb 13, 2014 2751 bclement made generic
+ * Feb 18, 2014 2631 mpduff Add ability to play sounds on join actions
*
*
*
@@ -110,7 +113,9 @@ public abstract class AbstractSessionView extends
private static final String SESSION_IMAGE_KEY = "sessionId.key";
- private SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss");
+ private static ThreadLocal dateFormatter = TimeUtil
+ .buildThreadLocalSimpleDateFormat("HH:mm:ss",
+ TimeZone.getTimeZone("GMT"));
/**
* Mapping of images used in the view so they are not constantly created and
@@ -152,7 +157,6 @@ public abstract class AbstractSessionView extends
imageMap = new HashMap();
fonts = new HashMap();
colors = new HashMap();
- dateFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
}
protected void initComponents(Composite parent) {
@@ -341,7 +345,7 @@ public abstract class AbstractSessionView extends
service.warnOfContentChange();
Date date = new Date(timestamp);
- String time = dateFormatter.format(date);
+ String time = dateFormatter.get().format(date);
String name = getDisplayName(userId);
@@ -450,7 +454,7 @@ public abstract class AbstractSessionView extends
String name, T userId, List ranges, Color color);
/**
- * Find keys words in body of message starting at offset. /**
+ * Find keys words in body of message starting at offset.
*
* @param builder
* @param offset
@@ -468,16 +472,28 @@ public abstract class AbstractSessionView extends
*/
protected void executeSightsSounds(AlertWord word) {
String filename = word.getSoundPath();
+ playSound(filename);
+ }
+
+ /**
+ * Play a sound.
+ *
+ * @param filename
+ * The file to play
+ */
+ protected void playSound(String filename) {
if (filename == null || filename.isEmpty()) {
return;
}
File soundFile = new File(filename);
- InputStream in;
+ InputStream in = null;
AudioStream as = null;
AudioData data = null;
try {
if (ads != null) {
AudioPlayer.player.stop(ads);
+ ads.close();
+ ads = null;
}
in = new FileInputStream(soundFile);
as = new AudioStream(in);
@@ -490,9 +506,29 @@ public abstract class AbstractSessionView extends
} catch (IOException e) {
statusHandler.handle(Priority.PROBLEM, "Unable to read sound file",
e);
+ } finally {
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
+ try {
+ if (as != null) {
+ as.close();
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
}
}
+ protected String getJoinFile() {
+ return Activator.getDefault().getPreferenceStore()
+ .getString(CollabPrefConstants.JOIN_FILE_FIELD_EDITOR_ID);
+ }
+
/*
* (non-Javadoc)
*
@@ -545,6 +581,13 @@ public abstract class AbstractSessionView extends
msgArchive = null;
}
+ try {
+ if (ads != null) {
+ ads.close();
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
super.dispose();
}
@@ -609,7 +652,7 @@ public abstract class AbstractSessionView extends
public void run() {
Color color = Display.getCurrent().getSystemColor(swtColor);
Date date = new Date();
- String time = dateFormatter.format(date);
+ String time = dateFormatter.get().format(date);
builder.insert(0, "(" + time + ") : ");
if (messagesText.getCharCount() != 0) {
builder.insert(0, "\n");
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java
index 3f202c20da..99400d9dbf 100644
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/PeerToPeerView.java
@@ -220,7 +220,7 @@ public class PeerToPeerView extends AbstractSessionView implements
return getViewSite().getSecondaryId();
} else if (peer instanceof UserId) {
return CollaborationConnection.getConnection().getContactsManager()
- .getDisplayName((UserId) peer);
+ .getDisplayName(peer);
} else {
return peer.getFQName();
}
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java
index e12bc74933..00754530bd 100644
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionFeedView.java
@@ -62,6 +62,7 @@ import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
* Jan 08, 2014 2563 bclement changes to match SiteConfigurationManager user sites config
* Jan 30, 2014 2698 bclement changed UserId to VenueParticipant
* Feb 13, 2014 2751 bclement VenueParticipant refactor
+ * Feb 18, 2014 2631 mpduff Add processJoinAlert()
*
*
*
@@ -83,7 +84,7 @@ public class SessionFeedView extends SessionView {
private List enabledSites;
- private List userEnabledSites;
+ private final List userEnabledSites;
private List colors;
@@ -183,12 +184,14 @@ public class SessionFeedView extends SessionView {
});
userAddSiteAction = new Action("Subscribe") {
+ @Override
public void run() {
userEnabledSites.add(getSelectedSite());
};
};
userRemoveSiteAction = new Action("Unsubscribe") {
+ @Override
public void run() {
userEnabledSites.remove(getSelectedSite());
}
@@ -292,8 +295,7 @@ public class SessionFeedView extends SessionView {
VenueParticipant selectedEntry = (VenueParticipant) selection
.getFirstElement();
Presence pres = session.getVenue().getPresence(selectedEntry);
- Object selectedSite = pres.getProperty(
- SiteConfigInformation.SITE_NAME);
+ Object selectedSite = pres.getProperty(SiteConfigInformation.SITE_NAME);
return selectedSite == null ? "" : selectedSite.toString();
}
@@ -319,8 +321,7 @@ public class SessionFeedView extends SessionView {
if (presence == null) {
return;
}
- Object site = presence.getProperty(
- SiteConfigInformation.SITE_NAME);
+ Object site = presence.getProperty(SiteConfigInformation.SITE_NAME);
if (site != null) {
setColorForSite(id, site.toString());
}
@@ -399,6 +400,25 @@ public class SessionFeedView extends SessionView {
super.participantPresenceUpdated(participant, presence);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.uf.viz.collaboration.ui.session.SessionView#processJoinAlert
+ * ()
+ */
+ @Override
+ protected void processJoinAlert() {
+ boolean includeFeed = Activator
+ .getDefault()
+ .getPreferenceStore()
+ .getBoolean(
+ CollabPrefConstants.INCLUDE_NWS_FEED_FIELD_EDITOR_ID);
+ if (includeFeed) {
+ super.processJoinAlert();
+ }
+ }
+
/*
* (non-Javadoc)
*
diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java
index bb11d2112f..e2dc48f635 100644
--- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java
+++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SessionView.java
@@ -78,7 +78,9 @@ import com.raytheon.uf.viz.collaboration.comm.provider.session.VenueSession;
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
+import com.raytheon.uf.viz.collaboration.ui.Activator;
import com.raytheon.uf.viz.collaboration.ui.actions.PrintLogActionContributionItem;
+import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
@@ -97,6 +99,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
* Dec 19, 2013 2563 bclement reworked participant event logic
* Jan 28, 2014 2698 bclement removed venue info
* Feb 13, 2014 2751 bclement VenueParticipant refactor
+ * Feb 18, 2014 2631 mpduff Add processJoinAlert()
*
*
*
@@ -452,7 +455,7 @@ public class SessionView extends AbstractSessionView
protected void styleAndAppendText(StringBuilder sb, int offset,
String name, VenueParticipant userId, String subject,
List ranges) {
- RGB rgb = colorManager.getColorFromUser((VenueParticipant) userId);
+ RGB rgb = colorManager.getColorFromUser(userId);
if (mappedColors.get(rgb) == null) {
Color col = new Color(Display.getCurrent(), rgb);
mappedColors.put(rgb, col);
@@ -627,6 +630,7 @@ public class SessionView extends AbstractSessionView
switch (type) {
case ARRIVED:
participantArrived(participant, description);
+ processJoinAlert();
break;
case DEPARTED:
participantDeparted(participant, description);
@@ -777,4 +781,14 @@ public class SessionView extends AbstractSessionView
return userId.getHandle();
}
+ /**
+ * Process a room join alert.
+ */
+ protected void processJoinAlert() {
+ boolean enabled = Activator.getDefault().getPreferenceStore()
+ .getBoolean(CollabPrefConstants.ENABLE_JOIN_EVENTS_FIELD_EDITOR_ID);
+ if (enabled) {
+ this.playSound(getJoinFile());
+ }
+ }
}
diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java
index c3d3f12305..dc1c67682b 100644
--- a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java
+++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java
@@ -57,6 +57,7 @@ import com.raytheon.uf.common.time.domain.api.ITimePoint;
* Jan 08, 2014 2615 bgonzale Added Calendar min and max methods.
* Added newGmtCalendar from a date method.
* Jan 28, 2014 2636 mpduff Removed unused methods.
+ * Feb 19, 2014 2631 mpduff Added buildThreadLocalSimpleDateFormat(String, TimeZone).
*
*
* @author njensen
@@ -623,4 +624,28 @@ public final class TimeUtil {
return calendar;
}
+ /**
+ * Get aThreadLocal object.
+ *
+ * @param format
+ * The date format
+ * @param timezone
+ * The timezone for the formatter
+ *
+ * @return ThreadLocal object
+ */
+ public static ThreadLocal buildThreadLocalSimpleDateFormat(
+ final String format, final TimeZone timezone) {
+ ThreadLocal dateFormatter = new ThreadLocal() {
+
+ @Override
+ protected SimpleDateFormat initialValue() {
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
+ sdf.setTimeZone(timezone);
+ return sdf;
+ }
+ };
+
+ return dateFormatter;
+ }
}