ofbiz-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doo...@apache.org
Subject svn commit: r917368 - in /ofbiz/trunk/framework/base/src/org/ofbiz/base: conversion/DateTimeConverters.java util/test/ObjectTypeTests.java
Date Mon, 01 Mar 2010 03:15:37 GMT
Author: doogie
Date: Mon Mar  1 03:15:36 2010
New Revision: 917368

URL: http://svn.apache.org/viewvc?rev=917368&view=rev
Log:
BUG FIX: Add DurationToFloat and Double converters.

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/DateTimeConverters.java
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.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=917368&r1=917367&r2=917368&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 Mon Mar
 1 03:15:36 2010
@@ -122,15 +122,23 @@
         }
     }
 
-    public static class DurationToList extends AbstractConverter<TimeDuration, List<TimeDuration>>
{
-        public DurationToList() {
-            super(TimeDuration.class, List.class);
+    public static class DurationToDouble extends AbstractConverter<TimeDuration, Double>
{
+        public DurationToDouble() {
+            super(TimeDuration.class, Double.class);
         }
 
-        public List<TimeDuration> convert(TimeDuration obj) throws ConversionException
{
-            List<TimeDuration> tempList = FastList.newInstance();
-            tempList.add(obj);
-            return tempList;
+        public Double convert(TimeDuration obj) throws ConversionException {
+             return Double.valueOf(TimeDuration.toLong(obj));
+        }
+    }
+
+    public static class DurationToFloat extends AbstractConverter<TimeDuration, Float>
{
+        public DurationToFloat() {
+            super(TimeDuration.class, Float.class);
+        }
+
+        public Float convert(TimeDuration obj) throws ConversionException {
+             return Float.valueOf(TimeDuration.toLong(obj));
         }
     }
 
@@ -144,6 +152,18 @@
         }
     }
 
+    public static class DurationToList extends AbstractConverter<TimeDuration, List<TimeDuration>>
{
+        public DurationToList() {
+            super(TimeDuration.class, List.class);
+        }
+
+        public List<TimeDuration> convert(TimeDuration obj) throws ConversionException
{
+            List<TimeDuration> tempList = FastList.newInstance();
+            tempList.add(obj);
+            return tempList;
+        }
+    }
+
     public static class DurationToSet extends AbstractConverter<TimeDuration, Set<TimeDuration>>
{
         public DurationToSet() {
             super(TimeDuration.class, Set.class);

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java?rev=917368&r1=917367&r2=917368&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java Mon Mar 
1 03:15:36 2010
@@ -404,8 +404,8 @@
     public void testTimeDuration() throws GeneralException {
         simpleTypeConvertTestSingleMulti("TimeDuration->String", duration, new String[]
{"String", "java.lang.String"}, "0:0:0:1:1:1:1");
         simpleTypeConvertTestSingleMulti("TimeDuration->BigDecimal", duration, new String[]
{"BigDecimal", "java.math.BigDecimal"}, new BigDecimal("3661001"));
-        //BUG simpleTypeConvertTestSingleMulti("TimeDuration->Double", duration, new String[]
{"Double", "java.lang.Double"}, Double.valueOf("3661001"));
-        //BUG simpleTypeConvertTestSingleMulti("TimeDuration->Float", duration, new String[]
{"Float", "java.lang.Float"}, Float.valueOf("3661001"));
+        simpleTypeConvertTestSingleMulti("TimeDuration->Double", duration, new String[]
{"Double", "java.lang.Double"}, Double.valueOf("3661001"));
+        simpleTypeConvertTestSingleMulti("TimeDuration->Float", duration, new String[]
{"Float", "java.lang.Float"}, Float.valueOf("3661001"));
         simpleTypeConvertTestSingleMulti("TimeDuration->Long", duration, new String[]
{"Long", "java.lang.Long"}, Long.valueOf("3661001"));
         simpleTypeConvertTestSingleMulti("TimeDuration->List", duration, new String[]
{"List", "java.util.List"}, list(duration));
         simpleTypeConvertTestSingleMulti("TimeDuration->Set", duration, new String[] {"Set",
"java.util.Set"}, set(duration));



Mime
View raw message