-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
In the corresponding class, to save date picked from datebox and time from timebox I have the following code:
@Temporal(TemporalType.DATE) private Date startDate; @Temporal(TemporalType.TIMESTAMP) private Date startTime;
The startDate saves correctly but startTime returns null. I can't find the way to pick the time from timebox and map to mysql.
TIA
ntsetso
Try same with 6.0.4
Thanks for replying
I worked a small example following your suggestion.
The model looks like
[ ... ] @Entity @Table(name = "workshop") public class Workshop { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private Date startDate; @Column(columnDefinition = "time") private Timestamp startTime; @Column(columnDefinition = "time") private Timestamp closeTime; [ ... ]
and in ZUL page
[ ... ] Date: <datebox value="@bind(varEvt.startDate)" format="dd-MM-yyyy" ></datebox> Start: <timebox value="@bind(varEvt.startTime)" format="HH:mm" ></timebox> Close: <timebox value="@bind(varEvt.closeTime)" format="HH:mm" ></timebox> [ ... ]
The data now saves correctly in mysql
+----+------------+-----------+-----------+ | id | startdate | starttime | closetime | +----+------------+-----------+-----------+ | 1 | 2013-01-31 | 07:00:00 | 08:30:00 | +----+------------+-----------+-----------+ 1 row in set (0.00 sec) mysql>
I was using ZK 6.0.0 and it returned "error converting java.util.Date to java.sql.Timestamp". I changed to
ZK 6.0.1. and then It worked.
The full example can be found at http://muchanga.net/zk/timetest.war
I will suggest you use binding with TimeStamp class something like this
In Your View Model
private Timestamp scheduledStartDate;// Add get/set methods
and in ZUL page
<timebox cols="20" format="a hh:mm:ss" value="@bind(vm.scheduledStartDate)"/>
I Just tested everything worked fine for me
i got this result.
2013-01-14 02:32:30.0
Asked: 2013-01-14 07:42:54 +0800
Seen: 50 times
Last updated: Jan 15 '13