For some business rule reason, I need to insert not just TIMESTAMP but also DATE and TIME in the database table.
Also, I am trying to set auto-enter for DATETIME columns programmatically because the auto-enter options are not working for DATETIME fields in Servoy version 5.1.x. (For more info about this see: http://forum.servoy.com/viewtopic.php?f=22&t=14491#p76836)
In any case, I have tried the following code in my create new record function (method):
creation_tstp = application.getTimeStamp();
creation_dt = application.getTimeStamp().getDate();
//creation_time = application.getTimeStamp().getTime();
creation_time = application.getTimeStamp().getHours() + ":" + application.getTimeStamp().getMinutes() + ":" + application.getTimeStamp().getSeconds();
creation_tstp = application.getTimeStamp(); returns the right value (the application timestamp).
I have problems with the other two.
- re creation_dt
creation_dt = application.getTimeStamp().getDate(); returns 12/31/1969 (in the db table is inserted as 1969-12-31).
- creation_time
creation_time = application.getTimeStamp().getHours() + “:” + application.getTimeStamp().getMinutes() + “:” + application.getTimeStamp().getSeconds(); returns a error. See below:
Caused by: java.lang.IllegalArgumentException: Setting dataprovider with name ‘creation_time’, type ‘DATETIME’ with value of wrong type 10:20:34
Interesting enough, I created a variable to ‘test’ the code that defines creation_time.
var test = application.getTimeStamp().getHours() + ":" + application.getTimeStamp().getMinutes() + ":" + application.getTimeStamp().getSeconds();
It returns what I was expecting. In addition, if I copy and paste (on the entry form) the value from test into creation_time, the value is accepted (inserted) without any error. But the same value cannot be inserted in creation_time = application.getTimeStamp().getHours() + “:” + application.getTimeStamp().getMinutes() + “:” + application.getTimeStamp().getSeconds();. I am not a programmer of the caliber of most people in this forum, but this doesn’t make sense to me.
- about getTime()
I don’t understand the getTime() object. It returns a number
1282239314082. Is this wrong?
Therefore I have not been able to use it to get creation_time = application.getTimeStamp().getTime(); It also throws an error.
Any help to resolve these issues will be more than appreciated!
JC