Bind Date#getTime() instead to get / set the raw timestamp in milliseconds.
<h:inputText value="#{bean.date.time}" />
Or, if you want to enter / display a human-readable date, just stick to #{bean.date} and use standard date converters.
<h:inputText value="#{bean.date}"> <f:convertDateTime type="date" dateType="short" /> </h:inputText>
In the backend, just use Date#getTime() to handle the timestamp.
Update : you should not clutter your model with the JDBC specification. java.util.Date represents a timestamp. Use java.sql.Timestamp only when you are going to save java.util.Date in the TIMESTAMP or DATETIME column of your database.
preparedStatement.setTimestamp(index, new Timestamp(bean.getDate().getTime()));
source share