From 7b177ae49f12b3fa3f74d39a57fd7a5418c0341d Mon Sep 17 00:00:00 2001 From: Johann Werner Date: Mon, 18 Nov 2013 11:22:53 +0100 Subject: [PATCH 1/5] cache date formatters on a per thread basis --- .../jdbcadaptor/_FrontBasePlugIn.java | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java index 7ad20c0e9cd..66db1b80cf7 100644 --- a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java +++ b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java @@ -71,6 +71,36 @@ public class _FrontBasePlugIn extends JDBCPlugIn { static final String _frontbaseSqlStatementForGettingTableNames = System.getProperty("jdbcadaptor.frontbase.sqlStatementForGettingTableNames", null); static final String _frontbaseContainsOperatorFix = System.getProperty("jdbcadaptor.frontbase.frontbaseContainsOperatorFix", null); + /** + * Formatter to use when handling date columns. Each thread has its own copy. + */ + private static final ThreadLocal DATE_FORMATTER = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd"); + } + }; + + /** + * Formatter to use when handling timestamp columns. Each thread has its own copy. + */ + private static final ThreadLocal TIMESTAMP_FORMATTER = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + } + }; + + /** + * Formatter to use when handling time only columns. Each thread has its own copy. + */ + private static final ThreadLocal TIME_FORMATTER = new ThreadLocal() { + @Override + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("HH:mm:ss.SSS"); + } + }; + public _FrontBasePlugIn(JDBCAdaptor jdbcadaptor) { super(jdbcadaptor); } @@ -1742,8 +1772,7 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { case FB_Time: { StringBuffer time = new StringBuffer("TIME '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); - SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss.SSS"); - format.format(d, time, new FieldPosition(0)); + TIME_FORMATTER.get().format(d, time, new FieldPosition(0)); time.append("'"); return time.toString(); } @@ -1751,8 +1780,7 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { case FB_TimeTZ: { StringBuffer time = new StringBuffer("TIME '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); - SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss.SSS"); - format.format(d, time, new FieldPosition(0)); + TIME_FORMATTER.get().format(d, time, new FieldPosition(0)); time.append(getTimeZone(NSTimeZone.defaultTimeZone())); time.append("'"); return time.toString(); @@ -1761,16 +1789,14 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { case FB_Timestamp: { StringBuffer time = new StringBuffer("TIMESTAMP '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - format.format(d, time, new FieldPosition(0)); + TIMESTAMP_FORMATTER.get().format(d, time, new FieldPosition(0)); time.append("'"); return time.toString(); } case FB_TimestampTZ: { StringBuffer time = new StringBuffer("TIMESTAMP '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - format.format(d, time, new FieldPosition(0)); + TIMESTAMP_FORMATTER.get().format(d, time, new FieldPosition(0)); time.append(getTimeZone(NSTimeZone.defaultTimeZone())); time.append("'"); return time.toString(); @@ -1778,8 +1804,7 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { case FB_Date: { StringBuffer time = new StringBuffer("DATE '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - format.format(d, time, new FieldPosition(0)); + DATE_FORMATTER.get().format(d, time, new FieldPosition(0)); time.append("'"); return time.toString(); } From 83f2053e7a728d39394e850616eabf23b59bb78c Mon Sep 17 00:00:00 2001 From: Johann Werner Date: Mon, 18 Nov 2013 11:43:02 +0100 Subject: [PATCH 2/5] resolve some generics warnings --- .../jdbcadaptor/_FrontBasePlugIn.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java index 66db1b80cf7..cff29fc0e57 100644 --- a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java +++ b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java @@ -346,7 +346,7 @@ public void updateLOBs(JDBCChannel channel, JDBCExpression expression, NSDiction try { Connection con = ((JDBCContext) channel.adaptorContext()).connection(); - NSMutableDictionary d = new NSMutableDictionary(); + NSMutableDictionary d = new NSMutableDictionary(); for (int i = 0; i < array.count(); i += 2) { d.setObjectForKey(getLobHandle(con, array.objectAtIndex(i), array.objectAtIndex(i + 1)), ((EOAttribute) array.objectAtIndex(i)).name()); @@ -642,7 +642,7 @@ public static boolean boolValueForKeyDefault(NSDictionary nsdictionary, String s public String schemaCreationScriptForEntities(NSArray allEntities, NSDictionary options) { StringBuffer result = new StringBuffer(); if (options == null) { - options = NSDictionary.EmptyDictionary; + options = NSDictionary.emptyDictionary(); } NSArray statements = schemaCreationStatementsForEntities(allEntities, options); int i = 0; @@ -680,30 +680,31 @@ public NSArray schemaCreationStatementsForEntities(NSArray> entityGroups = primaryKeyEntityGroupsForEntities(entities); + result.addObjectsFromArray(dropPrimaryKeySupportStatementsForEntityGroups(entityGroups)); } if (boolValueForKeyDefault(options, "dropTables", true)) { - NSArray nsarray2 = tableEntityGroupsForEntities(entities); - result.addObjectsFromArray(dropTableStatementsForEntityGroups(nsarray2)); + NSArray> entityGroups = tableEntityGroupsForEntities(entities); + result.addObjectsFromArray(dropTableStatementsForEntityGroups(entityGroups)); } if (boolValueForKeyDefault(options, "createTables", true)) { - NSArray nsarray3 = tableEntityGroupsForEntities(entities); - result.addObjectsFromArray(createTableStatementsForEntityGroups(nsarray3)); - result.addObjectsFromArray(createIndexStatementsForEntityGroups(nsarray3)); + NSArray> entityGroups = tableEntityGroupsForEntities(entities); + result.addObjectsFromArray(createTableStatementsForEntityGroups(entityGroups)); + result.addObjectsFromArray(createIndexStatementsForEntityGroups(entityGroups)); } if (boolValueForKeyDefault(options, "createPrimaryKeySupport", true)) { - NSArray nsarray4 = primaryKeyEntityGroupsForEntities(entities); - result.addObjectsFromArray(primaryKeySupportStatementsForEntityGroups(nsarray4)); + NSArray> entityGroups = primaryKeyEntityGroupsForEntities(entities); + result.addObjectsFromArray(primaryKeySupportStatementsForEntityGroups(entityGroups)); } if (boolValueForKeyDefault(options, "primaryKeyConstraints", true)) { - NSArray nsarray5 = tableEntityGroupsForEntities(entities); - result.addObjectsFromArray(primaryKeyConstraintStatementsForEntityGroups(nsarray5)); + NSArray> entityGroups = tableEntityGroupsForEntities(entities); + result.addObjectsFromArray(primaryKeyConstraintStatementsForEntityGroups(entityGroups)); } if (boolValueForKeyDefault(options, "foreignKeyConstraints", false)) { - NSArray nsarray6 = tableEntityGroupsForEntities(entities); - for (int i = 0; i < nsarray6.count(); i++) - result.addObjectsFromArray(_foreignKeyConstraintStatementsForEntityGroup((NSArray) nsarray6.objectAtIndex(i))); + NSArray> entityGroups = tableEntityGroupsForEntities(entities); + for (NSArray entityGroup : entityGroups) { + result.addObjectsFromArray(_foreignKeyConstraintStatementsForEntityGroup(entityGroup)); + } } result.addObject(_expressionForString("COMMIT")); return result; @@ -750,7 +751,7 @@ public NSArray dropTableStatementsForEntityGroup(NSArray primaryKeySupportStatementsForEntityGroup(NSArray entityGroup) { if (entityGroup == null) - return NSArray.EmptyArray; + return NSArray.emptyArray(); NSMutableArray result = new NSMutableArray(); @@ -850,7 +851,7 @@ public NSArray foreignKeyConstraintStatementsForRelationship(EO return new NSArray(_expressionForString(sql.toString())); } - return NSArray.EmptyArray; + return NSArray.emptyArray(); } /** @@ -878,7 +879,7 @@ public NSArray createTableStatementsForEntityGroup(NSArray createIndexStatementsForEntityGroup(NSArray primaryKeyConstraintStatementsForEntityGroup(NSA return new NSArray(_expressionForString(sql.toString())); } } - return NSArray.EmptyArray; + return NSArray.emptyArray(); } } @@ -1746,7 +1747,7 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { case FB_BLOB: case FB_CLOB: { if (!(obj instanceof String) && eoattribute.valueFactoryMethod() != null) { - Class valueClass = _NSUtilities.classWithName(eoattribute.className()); + Class valueClass = _NSUtilities.classWithName(eoattribute.className()); if (valueClass.isAssignableFrom(obj.getClass())) { obj = eoattribute.adaptorValueByConvertingAttributeValue(obj); } From b5bb1a1a5305e0d8d483f4bc5790cf070da65f6d Mon Sep 17 00:00:00 2001 From: Johann Werner Date: Mon, 18 Nov 2013 11:44:16 +0100 Subject: [PATCH 3/5] use existing method --- .../com/webobjects/jdbcadaptor/_FrontBasePlugIn.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java index cff29fc0e57..ad025353a40 100644 --- a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java +++ b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java @@ -1161,8 +1161,6 @@ public void addCreateClauseForAttribute(EOAttribute attribute) { sql.append(columnTypeStringForAttribute(attribute)); NSDictionary dictionary = attribute.userInfo(); - int internalType = internalTypeForExternal(attribute.externalType()); - boolean isLOB = internalType == FB_BLOB || internalType == FB_CLOB; if (dictionary == null) { _appendNotNullConstraintIfNecessary(attribute, sql); } @@ -1230,9 +1228,7 @@ private void _appendNotNullConstraintIfNecessary(EOAttribute attribute, StringBu } sql.append(" NOT NULL"); - int internalType = internalTypeForExternal(attribute.externalType()); - boolean isLOB = internalType == FB_BLOB || internalType == FB_CLOB; - if (isLOB) + if (isLOBAttribute(attribute)) sql.append(" DEFERRABLE INITIALLY DEFERRED"); } } From 82b8a27e532d8ac97b803bbbef8efc022546c24a Mon Sep 17 00:00:00 2001 From: Johann Werner Date: Mon, 18 Nov 2013 11:47:14 +0100 Subject: [PATCH 4/5] use constants and method from FrontBaseTypes there is already a class that packages the different value types so use it instead. deprecating the old values/method --- .../jdbcadaptor/FrontBaseTypes.java | 3 +- .../jdbcadaptor/_FrontBasePlugIn.java | 101 +++++++++++------- 2 files changed, 65 insertions(+), 39 deletions(-) diff --git a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/FrontBaseTypes.java b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/FrontBaseTypes.java index e59e3da7041..d2bfcae5b88 100644 --- a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/FrontBaseTypes.java +++ b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/FrontBaseTypes.java @@ -74,7 +74,6 @@ else if (externalType.equals("BLOB")) return FB_BLOB; else if (externalType.equals("CLOB")) return FB_CLOB; - else - return -1; + return -1; } } diff --git a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java index ad025353a40..1eb56e8daf6 100644 --- a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java +++ b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java @@ -372,11 +372,11 @@ String getLobHandle(Connection con, Object attribute, Object value) throws SQLEx // MS: This is weird, but to allow for people to build FrontBasePlugIn without actually // having the FrontBase JDBC driver installed, I've switched these two calls to be reflection. try { - switch (internalTypeForExternal(((EOAttribute) attribute).externalType())) { - case FB_BLOB: + switch (FrontBaseTypes.internalTypeForExternal(((EOAttribute) attribute).externalType())) { + case FrontBaseTypes.FB_BLOB: Method writeBLOBBytes = con.getClass().getMethod("writeBLOB", new Class[] { byte[].class }); return (String) writeBLOBBytes.invoke(con, new Object[] { ((NSData) value).bytes() }); - case FB_CLOB: + case FrontBaseTypes.FB_CLOB: Method writeCLOBString = con.getClass().getMethod("writeCLOB", new Class[] { String.class }); return (String) writeCLOBString.invoke(con, new Object[] { (String) value }); default: @@ -524,28 +524,51 @@ private boolean _newPrimaryKeys(int keyBatchSize, EOEntity eoentity, JDBCChannel return pksGenerated; } + @Deprecated protected static final int FB_Boolean = 1; + @Deprecated protected static final int FB_Integer = 2; + @Deprecated protected static final int FB_SmallInteger = 3; + @Deprecated protected static final int FB_Float = 4; + @Deprecated protected static final int FB_Real = 5; + @Deprecated protected static final int FB_Double = 6; + @Deprecated protected static final int FB_Numeric = 7; + @Deprecated protected static final int FB_Decimal = 8; + @Deprecated protected static final int FB_Character = 9; + @Deprecated protected static final int FB_VCharacter = 10; + @Deprecated protected static final int FB_Bit = 11; + @Deprecated protected static final int FB_VBit = 12; + @Deprecated protected static final int FB_Date = 13; + @Deprecated protected static final int FB_Time = 14; + @Deprecated protected static final int FB_TimeTZ = 15; + @Deprecated protected static final int FB_Timestamp = 16; + @Deprecated protected static final int FB_TimestampTZ = 17; + @Deprecated protected static final int FB_YearMonth = 18; + @Deprecated protected static final int FB_DayTime = 19; + @Deprecated protected static final int FB_CLOB = 20; + @Deprecated protected static final int FB_BLOB = 21; + @Deprecated protected static final int FB_TinyInteger = 22; + @Deprecated protected static final int FB_LongInteger = 23; protected static String notNullConstraintName(EOAttribute attribute) { @@ -571,6 +594,10 @@ protected static String quoteTableName(String s) { return "\"" + s.substring(0, i) + "\".\"" + s.substring(i + 1, s.length()) + "\""; } + /** + * @deprecated user {@link FrontBaseTypes#internalTypeForExternal(String)} instead + */ + @Deprecated protected static int internalTypeForExternal(String externalType) { String upperExternalType = externalType.toUpperCase(); if (upperExternalType.equals("BOOLEAN")) @@ -1023,9 +1050,9 @@ public NSArray statementsToInsertColumnForAttribute(EOAttribute } private String statementToCreateDataTypeClause(EOSchemaSynchronization.ColumnTypes columntypes) { - switch (internalTypeForExternal(columntypes.name())) { - case FB_Decimal: - case FB_Numeric: + switch (FrontBaseTypes.internalTypeForExternal(columntypes.name())) { + case FrontBaseTypes.FB_Decimal: + case FrontBaseTypes.FB_Numeric: int j = columntypes.precision(); if (j == 0) return columntypes.name(); @@ -1035,11 +1062,11 @@ private String statementToCreateDataTypeClause(EOSchemaSynchronization.ColumnTyp else return columntypes.name() + "(" + j + "," + k + ")"; - case FB_Float: - case FB_Bit: - case FB_VBit: - case FB_Character: - case FB_VCharacter: + case FrontBaseTypes.FB_Float: + case FrontBaseTypes.FB_Bit: + case FrontBaseTypes.FB_VBit: + case FrontBaseTypes.FB_Character: + case FrontBaseTypes.FB_VCharacter: int l = columntypes.width(); if (l == 0) l = columntypes.precision(); @@ -1047,7 +1074,7 @@ private String statementToCreateDataTypeClause(EOSchemaSynchronization.ColumnTyp return columntypes.name(); else return columntypes.name() + "(" + l + ")"; - case FB_Timestamp: + case FrontBaseTypes.FB_Timestamp: int m = columntypes.precision(); if (m == 0) return columntypes.name(); @@ -1636,8 +1663,8 @@ public boolean shouldUseBindVariableForAttribute(EOAttribute eoattribute) { } private boolean isLOBAttribute(EOAttribute att) { - int internalType = internalTypeForExternal(att.externalType()); - return internalType == FB_BLOB || internalType == FB_CLOB; + int internalType = FrontBaseTypes.internalTypeForExternal(att.externalType()); + return internalType == FrontBaseTypes.FB_BLOB || internalType == FrontBaseTypes.FB_CLOB; } @Override @@ -1732,16 +1759,16 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { throw new EOGeneralAdaptorException("Attribute " + eoattribute.name() + " on entity " + eoattribute.entity().name() + " with prototype named " + eoattribute.prototypeName() + " has no external type defined"); } - switch (internalTypeForExternal(eoattribute.externalType())) { - case FB_Character: - case FB_VCharacter: { + switch (FrontBaseTypes.internalTypeForExternal(eoattribute.externalType())) { + case FrontBaseTypes.FB_Character: + case FrontBaseTypes.FB_VCharacter: { return escapedString(obj); } - case FB_DayTime: { + case FrontBaseTypes.FB_DayTime: { return escapedString(obj); } - case FB_BLOB: - case FB_CLOB: { + case FrontBaseTypes.FB_BLOB: + case FrontBaseTypes.FB_CLOB: { if (!(obj instanceof String) && eoattribute.valueFactoryMethod() != null) { Class valueClass = _NSUtilities.classWithName(eoattribute.className()); if (valueClass.isAssignableFrom(obj.getClass())) { @@ -1757,8 +1784,8 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { _lobList.addObject(obj); return "NULL"; } - case FB_VBit: - case FB_Bit: { + case FrontBaseTypes.FB_VBit: + case FrontBaseTypes.FB_Bit: { if (obj instanceof NSData) { return formatBit((NSData) obj); } @@ -1766,7 +1793,7 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { return "ERROR: Can not convert value from " + obj + " to Bit or Byte data type"; } } - case FB_Time: { + case FrontBaseTypes.FB_Time: { StringBuffer time = new StringBuffer("TIME '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); TIME_FORMATTER.get().format(d, time, new FieldPosition(0)); @@ -1774,7 +1801,7 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { return time.toString(); } - case FB_TimeTZ: { + case FrontBaseTypes.FB_TimeTZ: { StringBuffer time = new StringBuffer("TIME '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); TIME_FORMATTER.get().format(d, time, new FieldPosition(0)); @@ -1783,14 +1810,14 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { return time.toString(); } - case FB_Timestamp: { + case FrontBaseTypes.FB_Timestamp: { StringBuffer time = new StringBuffer("TIMESTAMP '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); TIMESTAMP_FORMATTER.get().format(d, time, new FieldPosition(0)); time.append("'"); return time.toString(); } - case FB_TimestampTZ: { + case FrontBaseTypes.FB_TimestampTZ: { StringBuffer time = new StringBuffer("TIMESTAMP '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); TIMESTAMP_FORMATTER.get().format(d, time, new FieldPosition(0)); @@ -1798,14 +1825,14 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { time.append("'"); return time.toString(); } - case FB_Date: { + case FrontBaseTypes.FB_Date: { StringBuffer time = new StringBuffer("DATE '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); DATE_FORMATTER.get().format(d, time, new FieldPosition(0)); time.append("'"); return time.toString(); } - case FB_Boolean: { + case FrontBaseTypes.FB_Boolean: { if (obj instanceof Boolean) { return obj.toString(); } @@ -1831,15 +1858,15 @@ else if (((Number) obj).intValue() == 0) { return "TRUE"; } } - case FB_SmallInteger: - case FB_Float: - case FB_Real: - case FB_Double: - case FB_LongInteger: - case FB_TinyInteger: - case FB_Numeric: - case FB_Integer: - case FB_Decimal: { + case FrontBaseTypes.FB_SmallInteger: + case FrontBaseTypes.FB_Float: + case FrontBaseTypes.FB_Real: + case FrontBaseTypes.FB_Double: + case FrontBaseTypes.FB_LongInteger: + case FrontBaseTypes.FB_TinyInteger: + case FrontBaseTypes.FB_Numeric: + case FrontBaseTypes.FB_Integer: + case FrontBaseTypes.FB_Decimal: { if (obj instanceof BigDecimal) { return ((BigDecimal) obj).setScale(eoattribute.scale(), BigDecimal.ROUND_HALF_UP).toString(); } From 6b3cba409604659182a5c21c41898ad8c3890007 Mon Sep 17 00:00:00 2001 From: Johann Werner Date: Tue, 7 Jan 2014 10:07:45 +0100 Subject: [PATCH 5/5] include changes from #517 --- .../com/webobjects/jdbcadaptor/_FrontBasePlugIn.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java index 1eb56e8daf6..420db3693af 100644 --- a/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java +++ b/Frameworks/PlugIns/FrontBasePlugIn/Sources/com/webobjects/jdbcadaptor/_FrontBasePlugIn.java @@ -40,7 +40,6 @@ import com.webobjects.foundation.NSPropertyListSerialization; import com.webobjects.foundation.NSRange; import com.webobjects.foundation.NSSelector; -import com.webobjects.foundation.NSTimeZone; import com.webobjects.foundation.NSTimestamp; import com.webobjects.foundation._NSUtilities; @@ -1804,8 +1803,9 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { case FrontBaseTypes.FB_TimeTZ: { StringBuffer time = new StringBuffer("TIME '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); - TIME_FORMATTER.get().format(d, time, new FieldPosition(0)); - time.append(getTimeZone(NSTimeZone.defaultTimeZone())); + SimpleDateFormat formatter = TIME_FORMATTER.get(); + formatter.format(d, time, new FieldPosition(0)); + time.append(getTimeZone(formatter.getTimeZone())); time.append("'"); return time.toString(); } @@ -1820,8 +1820,9 @@ public String formatValueForAttribute(Object obj, EOAttribute eoattribute) { case FrontBaseTypes.FB_TimestampTZ: { StringBuffer time = new StringBuffer("TIMESTAMP '"); Date d = (Date)eoattribute.adaptorValueByConvertingAttributeValue(obj); - TIMESTAMP_FORMATTER.get().format(d, time, new FieldPosition(0)); - time.append(getTimeZone(NSTimeZone.defaultTimeZone())); + SimpleDateFormat formatter = TIMESTAMP_FORMATTER.get(); + formatter.format(d, time, new FieldPosition(0)); + time.append(getTimeZone(formatter.getTimeZone())); time.append("'"); return time.toString(); }