You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2014/04/18 18:48:42 UTC
svn commit: r1588513 - in /ofbiz/branches/release12.04: ./
framework/base/src/org/ofbiz/base/conversion/
framework/base/src/org/ofbiz/base/util/test/
framework/minilang/src/org/ofbiz/minilang/method/envops/
Author: adrianc
Date: Fri Apr 18 16:48:41 2014
New Revision: 1588513
URL: http://svn.apache.org/r1588513
Log:
Merged revision(s) 1585033 from ofbiz/trunk:
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.
........
Merged revision(s) 1585574 from ofbiz/trunk:
Fixed a bug in rev 1585033. Reported by Gareth Carter on the dev mailing list.
........
Merged revision(s) 1585958 from ofbiz/trunk:
Modified the String to java.sql.Date conversion. Replace deprecated constructor call with a Calendar implementation.
........
Merged revision(s) 1585959 from ofbiz/trunk:
Bug fix in ObjectTypeTests - a java.sql.Date instance created in one time zone is not equal to another instance created in another time zone.
........
Merged revision(s) 1586987 from ofbiz/trunk:
Fix for some Java versions that throw an exception when the String includes a "+". https://issues.apache.org/jira/browse/OFBIZ-5616
........
Modified:
ofbiz/branches/release12.04/ (props changed)
ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java
ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java
Propchange: ofbiz/branches/release12.04/
------------------------------------------------------------------------------
Merged /ofbiz/trunk:r1585033,1585574,1585958-1585959,1586987
Modified: ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java?rev=1588513&r1=1588512&r2=1588513&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java (original)
+++ ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java Fri Apr 18 16:48:41 2014
@@ -567,7 +567,11 @@ 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);
+ Calendar cal = UtilDateTime.toCalendar(parsedDate, timeZone, locale);
+ cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ return new java.sql.Date(cal.getTimeInMillis());
} catch (ParseException e) {
throw new ConversionException(e);
}
Modified: ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java?rev=1588513&r1=1588512&r2=1588513&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java (original)
+++ ofbiz/branches/release12.04/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java Fri Apr 18 16:48:41 2014
@@ -34,10 +34,13 @@ import org.ofbiz.base.test.GenericTestCa
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.ObjectType;
import org.ofbiz.base.util.TimeDuration;
+import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilXml;
import org.w3c.dom.Document;
+import com.ibm.icu.util.Calendar;
+
@SourceMonitored
public class ObjectTypeTests extends GenericTestCaseBase {
public static final String module = ObjectTypeTests.class.getName();
@@ -53,7 +56,7 @@ public class ObjectTypeTests extends Gen
private final Timestamp tstmp = new Timestamp(781L);
private final Timestamp ntstmp;
private final java.util.Date utlDt = new java.util.Date(781);
- private final java.sql.Date sqlDt = new java.sql.Date(-129600000);
+ private final java.sql.Date sqlDt;
private final java.sql.Time sqlTm = new java.sql.Time(2096000);
private final List<Object> list;
private final Map<String, Object> map;
@@ -72,6 +75,10 @@ public class ObjectTypeTests extends Gen
map.put("two", "2");
map.put("three", "3");
set = new LinkedHashSet<Object>(list);
+ Calendar cal = UtilDateTime.getCalendarInstance(localeData.goodTimeZone, localeData.goodLocale);
+ cal.set(1969, Calendar.DECEMBER, 31, 0, 0, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ sqlDt = new java.sql.Date(cal.getTimeInMillis());
}
public static class LocaleData {
Modified: ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java?rev=1588513&r1=1588512&r2=1588513&view=diff
==============================================================================
--- ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java (original)
+++ ofbiz/branches/release12.04/framework/minilang/src/org/ofbiz/minilang/method/envops/SetCalendar.java Fri Apr 18 16:48:41 2014
@@ -79,6 +79,11 @@ public final class SetCalendar extends M
return elementModified;
}
+ // Fix for some Java versions that throw an exception when the String includes a "+".
+ private static int parseInt(String intStr) {
+ return Integer.parseInt(intStr.replace("+", ""));
+ }
+
private final FlexibleStringExpander daysFse;
private final FlexibleStringExpander defaultFse;
private final FlexibleMapAccessor<Object> fieldFma;
@@ -194,25 +199,25 @@ public final class SetCalendar extends M
}
fromStamp = (Timestamp) MiniLangUtil.convertType(newValue, java.sql.Timestamp.class, locale, timeZone, UtilDateTime.DATE_TIME_FORMAT);
if (!this.yearsFse.isEmpty()) {
- years= Integer.parseInt(this.yearsFse.expandString(methodContext.getEnvMap()));
+ years= parseInt(this.yearsFse.expandString(methodContext.getEnvMap()));
}
if (!this.monthsFse.isEmpty()) {
- months = Integer.parseInt(this.monthsFse.expandString(methodContext.getEnvMap()));
+ months = parseInt(this.monthsFse.expandString(methodContext.getEnvMap()));
}
if (!this.daysFse.isEmpty()) {
- days = Integer.parseInt(this.daysFse.expandString(methodContext.getEnvMap()));
+ days = parseInt(this.daysFse.expandString(methodContext.getEnvMap()));
}
if (!this.hoursFse.isEmpty()) {
- hours = Integer.parseInt(this.hoursFse.expandString(methodContext.getEnvMap()));
+ hours = parseInt(this.hoursFse.expandString(methodContext.getEnvMap()));
}
if (!this.minutesFse.isEmpty()) {
- minutes = Integer.parseInt(this.minutesFse.expandString(methodContext.getEnvMap()));
+ minutes = parseInt(this.minutesFse.expandString(methodContext.getEnvMap()));
}
if (!this.secondsFse.isEmpty()) {
- seconds = Integer.parseInt(this.secondsFse.expandString(methodContext.getEnvMap()));
+ seconds = parseInt(this.secondsFse.expandString(methodContext.getEnvMap()));
}
if (!this.millisFse.isEmpty()) {
- millis = Integer.parseInt(this.millisFse.expandString(methodContext.getEnvMap()));
+ millis = parseInt(this.millisFse.expandString(methodContext.getEnvMap()));
}
} catch (Exception e) {
throw new MiniLangRuntimeException("Exception thrown while parsing attributes: " + e.getMessage(), this);