When working with Hibernate (or another ORM) in combination with mySQL datetime (mySql Type) fields are mapped to timestamp(Java Type).
Now timestamp is a subclass of Date so you can use this directly as value in a t:calendarfield, the date is shown correctly, but if you change the value an error happens.
When working with a value map (HashMap<String, Object>) and you insert a timestamp, the calendarfield shows, as already mentioned before, the right date, but when you change the value, not a timestamp but a string value is set back. The cause is that t:calendarfield can not handle type timestamp, you have to convert to a date field. Please don't try to cast like (Date)timestampField, this won't work. You've to create a new Date field and set the timestamp values.
Example for putting the value in:
Code:
Map<String, Object> values = new HashMap<String, Object>();
Date date = null;
Timestamp timestamp = entity.getTimestamp();
if (timestamp!=null) {
date = new Date(timestamp.getTime());
}
values.put("Date", date);
Example for receiving the value:
Code:
Timestamp timestamp = null;
Date date = (Date)values.get("Date");
if (date!=null) {
timestamp = new Timestamp(date.getTime());
}
entity.setTimestamp(timestamp);