Author: degenaro
Date: Sat Mar 16 10:05:34 2013
New Revision: 1457230

URL: http://svn.apache.org/r1457230
Log:
UIMA-2734 DUCC webserver (WS) employ thread-safe Date formatting 

Added:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/SynchronizedSimpleDateFormat.java
Modified:
    
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStamp.java
    
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStampConvert.java

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/SynchronizedSimpleDateFormat.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/SynchronizedSimpleDateFormat.java?rev=1457230&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/SynchronizedSimpleDateFormat.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/SynchronizedSimpleDateFormat.java
 Sat Mar 16 10:05:34 2013
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.common.utils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+public class SynchronizedSimpleDateFormat {
+
+       private SimpleDateFormat simpleDateFormat;
+       
+       public SynchronizedSimpleDateFormat() {
+               simpleDateFormat = new SimpleDateFormat();
+       }
+       
+       public SynchronizedSimpleDateFormat(String pattern) {
+               simpleDateFormat = new SimpleDateFormat(pattern);
+       }
+       
+       public void setTimeZone(TimeZone zone) {
+               synchronized(simpleDateFormat) {
+                       simpleDateFormat.setTimeZone(zone);
+               }
+       }
+       
+       public String format(Date date) {
+               synchronized(simpleDateFormat) {
+                       return simpleDateFormat.format(date);
+               }
+       }
+       
+       public Date parse(String source) throws ParseException {
+               synchronized(simpleDateFormat) {
+                       return simpleDateFormat.parse(source);
+               }
+       }
+}

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStamp.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStamp.java?rev=1457230&r1=1457229&r2=1457230&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStamp.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStamp.java
 Sat Mar 16 10:05:34 2013
@@ -18,7 +18,6 @@
 */
 package org.apache.uima.ducc.common.utils;
 
-import java.text.SimpleDateFormat;
 import java.util.Date;
 
 public class TimeStamp {
@@ -27,7 +26,7 @@ public class TimeStamp {
                return ""+System.currentTimeMillis();
        }
        
-       public static SimpleDateFormat simpleDateFormat = new 
SimpleDateFormat("yyyy.MM.dd HH:mm:ss EEE");
+       public static SynchronizedSimpleDateFormat simpleDateFormat = new 
SynchronizedSimpleDateFormat("yyyy.MM.dd HH:mm:ss EEE");
        
        public static String simpleFormat(String millis) {
                String retVal = "";

Modified: 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStampConvert.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStampConvert.java?rev=1457230&r1=1457229&r2=1457230&view=diff
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStampConvert.java
 (original)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/TimeStampConvert.java
 Sat Mar 16 10:05:34 2013
@@ -18,12 +18,11 @@
 */
 package org.apache.uima.ducc.common.utils;
 
-import java.text.SimpleDateFormat;
 import java.util.Date;
 
 public class TimeStampConvert {
 
-       public static SimpleDateFormat simpleDateFormat = new 
SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSSZ");
+       public static SynchronizedSimpleDateFormat simpleDateFormat = new 
SynchronizedSimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSSZ");
        
        public static Date simpleFormat(String formattedDate) {
                Date date = null;


Reply via email to