summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java9
-rw-r--r--server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java25
2 files changed, 34 insertions, 0 deletions
diff --git a/server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java b/server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java
index cddf2d8a42..7c252d78f2 100644
--- a/server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java
+++ b/server/src/com/vaadin/data/util/converter/DateToSqlDateConverter.java
@@ -44,6 +44,10 @@ public class DateToSqlDateConverter implements Converter<Date, java.sql.Date> {
+ targetType.getName() + ")");
}
+ if (value == null) {
+ return null;
+ }
+
return new java.sql.Date(value.getTime());
}
@@ -56,6 +60,11 @@ public class DateToSqlDateConverter implements Converter<Date, java.sql.Date> {
+ getPresentationType().getName() + " (targetType was "
+ targetType.getName() + ")");
}
+
+ if (value == null) {
+ return null;
+ }
+
return new Date(value.getTime());
}
diff --git a/server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java b/server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java
new file mode 100644
index 0000000000..685404ded6
--- /dev/null
+++ b/server/tests/src/com/vaadin/tests/data/converter/TestDateToSqlDateConverter.java
@@ -0,0 +1,25 @@
+package com.vaadin.tests.data.converter;
+
+import java.util.Date;
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import com.vaadin.data.util.converter.DateToSqlDateConverter;
+
+public class TestDateToSqlDateConverter extends TestCase {
+
+ DateToSqlDateConverter converter = new DateToSqlDateConverter();
+
+ public void testNullConversion() {
+ assertEquals(null,
+ converter.convertToModel(null, java.sql.Date.class, null));
+ }
+
+ public void testValueConversion() {
+ Date testDate = new Date(100, 0, 1);
+ long time = testDate.getTime();
+ assertEquals(testDate, converter.convertToModel(new java.sql.Date(time),
+ java.sql.Date.class, Locale.ENGLISH));
+ }
+}