svn commit: r611102 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r611102 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java

lektran
Author: lektran
Date: Fri Jan 11 00:20:03 2008
New Revision: 611102

URL: http://svn.apache.org/viewvc?rev=611102&view=rev
Log:
Workaround a problem where DateFormat parses 00:00:00.2 to 00:00:00.002

Modified:
    ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java

Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java?rev=611102&r1=611101&r2=611102&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java (original)
+++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/ObjectType.java Fri Jan 11 00:20:03 2008
@@ -581,6 +581,14 @@
                     // hack to mimic Timestamp.valueOf() method
                     if (str.length() > 0 && !str.contains(".")) {
                         str = str + ".0";
+                    } else {
+                        // DateFormat has a funny way of parsing milliseconds:
+                        // 00:00:00.2 parses to 00:00:00.002
+                        // so we'll add zeros to the end to get 00:00:00.200
+                        String[] timeSplit = str.split("[.]");
+                        if (timeSplit.length > 1 && timeSplit[1].length() < 3) {
+                            str = str + "000".substring(timeSplit[1].length());
+                        }
                     }
                 } else {
                     df = UtilDateTime.toDateTimeFormat(format, timeZone, null);