Author: adrianc
Date: Sat Apr 5 09:46:58 2014
New Revision: 1585033
URL: http://svn.apache.org/r1585033
Log:
Fixed a bug in String to java.sql.Date conversion. If the Date object includes
time information, then the JDBC driver will adjust the date according to the
default time zone - causing the wrong date to be stored in some circumstances.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java?rev=1585033&r1=1585032&r2=1585033&view=diff
==============================================================================
---
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
(original)
+++
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
Sat Apr 5 09:46:58 2014
@@ -555,6 +555,7 @@ public class DateTimeConverters implemen
return ObjectType.instanceOf(sourceClass, this.getSourceClass())
&& targetClass == this.getTargetClass();
}
+ @SuppressWarnings("deprecation")
public java.sql.Date convert(String obj, Locale locale, TimeZone
timeZone, String formatString) throws ConversionException {
String trimStr = obj.trim();
if (trimStr.length() == 0) {
@@ -567,7 +568,8 @@ public class DateTimeConverters implemen
df = UtilDateTime.toDateFormat(formatString, timeZone, locale);
}
try {
- return new java.sql.Date(df.parse(trimStr).getTime());
+ java.util.Date parsedDate = df.parse(trimStr);
+ return new java.sql.Date(parsedDate.getYear(),
parsedDate.getMonth(), parsedDate.getDay());
} catch (ParseException e) {
throw new ConversionException(e);
}