You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by ct...@apache.org on 2009/01/28 09:16:22 UTC
svn commit: r738400 -
/webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XsdUtils.java
Author: ctwiner
Date: Wed Jan 28 08:16:22 2009
New Revision: 738400
URL: http://svn.apache.org/viewvc?rev=738400&view=rev
Log:
fix for MUSE-297
Modified:
webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XsdUtils.java
Modified: webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XsdUtils.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XsdUtils.java?rev=738400&r1=738399&r2=738400&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XsdUtils.java (original)
+++ webservices/muse/trunk/modules/muse-util-xml/src/org/apache/muse/util/xml/XsdUtils.java Wed Jan 28 08:16:22 2009
@@ -20,7 +20,6 @@
package org.apache.muse.util.xml;
-import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -49,12 +48,20 @@
public static final String PREFIX = "xsd";
- //
- // Used to format dates in the XMLSchema dateTime format
- //
- private static DateFormat _FORMATTER =
- new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
-
+ /*
+ * Used to format dates in the XMLSchema dateTime format
+ * https://issues.apache.org/jira/browse/MUSE-297
+ */
+ private static ThreadLocal _FORMATTER_TLS = new ThreadLocal(){
+ protected Object initialValue() {
+ return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ }
+ };
+
+ private static SimpleDateFormat _FORMATTER() {
+ return (SimpleDateFormat)_FORMATTER_TLS.get();
+ };
+
public static final QName ANY_TYPE_QNAME =
new QName(NAMESPACE_URI, "anyType", PREFIX);
@@ -421,7 +428,7 @@
public static Date getLocalTime(String dateTimeString)
throws ParseException
{
- return _FORMATTER.parse(dateTimeString);
+ return _FORMATTER().parse(dateTimeString);
}
/**
@@ -452,16 +459,19 @@
*/
public static String getLocalTimeString(Date date)
{
+ // keep the copy, don't hit tls again.
+ SimpleDateFormat formatter = _FORMATTER();
+
//
// if we leave this date w/o a +N:00 postfix, calling code
// will assume it is UTC
//
- String dateWithoutTimeZone = _FORMATTER.format(date);
+ String dateWithoutTimeZone = formatter.format(date);
//
// figure out whether we're before (-) or after (+) UTC
//
- TimeZone timeZone = _FORMATTER.getTimeZone();
+ TimeZone timeZone = formatter.getTimeZone();
long offset = timeZone.getOffset(date.getTime());
char sign = offset < 0 ? '-' : '+';