package com.itmill.toolkit.demo.sampler.features.dates;\r
\r
import java.text.DateFormat;\r
+import java.util.Date;\r
\r
import com.itmill.toolkit.data.Property;\r
import com.itmill.toolkit.data.Property.ValueChangeEvent;\r
public void valueChange(ValueChangeEvent event) {\r
// Get the new value and format it to the current locale\r
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT);\r
- String dateOut = dateFormatter.format(event.getProperty().getValue());\r
- // Show notification\r
- getWindow().showNotification("Starting date: " + dateOut);\r
+ Object value = event.getProperty().getValue();\r
+ if (value == null || !(value instanceof Date)) {\r
+ getWindow().showNotification("Invalid date entered");\r
+ } else {\r
+ String dateOut = dateFormatter.format(value);\r
+ // Show notification\r
+ getWindow().showNotification("Starting date: " + dateOut);\r
+ }\r
}\r
}\r