Stored datetime values are milliseconds since epoch. They do not *have a* timezone, they are *rendered in* a timezone. Having understood this, please revisit what you're seeing, and let us know if you think you've got a bug.
Announcement
Collapse
No announcement yet.
X
-
Hi isomorphic,
Here is what I have found.
In the test case, I have modified the line code when I set the attribute date with the code:
Code:r.setAttribute("date",DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date(),TimeZone.createTimeZone(0)));
With this changes, when I click the create button, the developer console shows the RPC add operation as follows:
Request:
{
dataSource:"testcase",
operationType:"add",
data:{
date:"2012-04-07 10:02:48"
},
showPrompt:true,
oldValues:{
date:"2012-04-07 10:02:48"
},
requestId:"testcase$6271",
bypassCache:true
}
Response:
[
{
data:[
{
dateID:6,
date:new Date(1333792968000)
}
],
invalidateCache:false,
isDSResponse:true,
operationType:"add",
queueStatus:0,
status:0
}
]
In the client desktop where I use the browser shows the time 12:02 so the date is sent in GMT as expected.
But the problem is in the Mysql Query to insert the date in the database.
Here is the log from the server log:
Code:=== 2012-04-07 12:02:48,472 [-109] INFO RequestContext - URL: '/plantillaIdeiak/sc/IDACall', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.3; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': MSIE with Accept-Encoding header, ready for compressed JS === 2012-04-07 12:02:48,472 [-109] DEBUG XML - Parsed XML from (in memory stream): 0ms === 2012-04-07 12:02:48,472 [-109] DEBUG RPCManager - Processing 1 requests. === 2012-04-07 12:02:48,472 [-109] DEBUG RPCManager - Request #1 (DSRequest) payload: { values:{ date:"2012-04-07 10:02:48" }, operationConfig:{ dataSource:"testcase", operationType:"add" }, appID:"builtinApplication", operation:"testcase_add", oldValues:{ date:"2012-04-07 10:02:48" }, criteria:{ } } === 2012-04-07 12:02:48,488 [-109] INFO IDACall - Performing 1 operation(s) === 2012-04-07 12:02:48,488 [-109] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null === 2012-04-07 12:02:48,488 [-109] DEBUG DeclarativeSecurity - DataSource testcase is not in the pre-checked list, processing... === 2012-04-07 12:02:48,488 [-109] DEBUG AppBase - [builtinApplication.testcase_add] No userTypes defined, allowing anyone access to all operations for this application === 2012-04-07 12:02:48,488 [-109] DEBUG AppBase - [builtinApplication.testcase_add] No public zero-argument method named '_testcase_add' found, performing generic datasource operation === 2012-04-07 12:02:48,488 [-109] INFO SQLDataSource - [builtinApplication.testcase_add] Performing add operation with criteria: {date:"2012-04-07 10:02:48"} values: {date:new Date(1333792968000)} === 2012-04-07 12:02:48,488 [-109] DEBUG SQLValuesClause - [builtinApplication.testcase_add] Sequences: {dateID=__default} === 2012-04-07 12:02:48,614 [-112] INFO RequestContext - URL: '/plantillaIdeiak/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.3; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': MSIE with Accept-Encoding header, ready for compressed JS === 2012-04-07 12:02:48,848 [-109] DEBUG SQLConnectionManager - [builtinApplication.testcase_add] Returning borrowed connection '29206269' === 2012-04-07 12:02:49,253 [-109] DEBUG SQLTransaction - [builtinApplication.testcase_add] Started new Mysql transaction "29206269" === 2012-04-07 12:02:49,253 [-109] DEBUG SQLDriver - [builtinApplication.testcase_add] About to execute SQL update in 'Mysql' using connection'29206269' === 2012-04-07 12:02:49,253 [-109] INFO SQLDriver - [builtinApplication.testcase_add] Executing SQL update on 'Mysql': INSERT INTO testcase (date) VALUES ('2012-04-07 12:02:48') === 2012-04-07 12:02:49,363 [-109] DEBUG SQLDataSource - [builtinApplication.testcase_add] add operation affected 1 rows === 2012-04-07 12:02:49,363 [-109] DEBUG MysqlDriver - [builtinApplication.testcase_add] fetchLastRow data - primaryKeysPresent: {}sequencesNotPresent: [dateID] === 2012-04-07 12:02:49,363 [-109] DEBUG SQLDriver - [builtinApplication.testcase_add] About to execute SQL query in 'Mysql' using connection '29206269' === 2012-04-07 12:02:49,363 [-109] INFO SQLDriver - [builtinApplication.testcase_add] Executing SQL query on 'Mysql': SELECT LAST_INSERT_ID() === 2012-04-07 12:02:49,456 [-109] INFO SQLDataSource - [builtinApplication.testcase_add] primaryKeys: {dateID=6} === 2012-04-07 12:02:49,456 [-109] DEBUG DeclarativeSecurity - [builtinApplication.testcase_add] Processing security checks for DataSource null, field null === 2012-04-07 12:02:49,456 [-109] DEBUG DeclarativeSecurity - [builtinApplication.testcase_add] DataSource testcase is not in the pre-checked list, processing... === 2012-04-07 12:02:49,456 [-109] DEBUG AppBase - [builtinApplication.testcase_add, builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application === 2012-04-07 12:02:49,456 [-109] DEBUG AppBase - [builtinApplication.testcase_add, builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation === 2012-04-07 12:02:49,456 [-109] INFO SQLDataSource - [builtinApplication.testcase_add, builtinApplication.null] Performing fetch operation with criteria: {dateID:6} values: {dateID:6} === 2012-04-07 12:02:49,456 [-109] INFO SQLDataSource - [builtinApplication.testcase_add, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause === 2012-04-07 12:02:49,456 [-109] INFO SQLDataSource - [builtinApplication.testcase_add, builtinApplication.null] Executing SQL query on 'Mysql': SELECT testcase.date, testcase.dateID FROM testcase WHERE (testcase.dateID='6') === 2012-04-07 12:02:49,456 [-109] DEBUG SQLDriver - [builtinApplication.testcase_add, builtinApplication.null] About to execute SQL query in 'Mysql' using connection '29206269' === 2012-04-07 12:02:49,456 [-109] INFO SQLDriver - [builtinApplication.testcase_add, builtinApplication.null] Executing SQL query on 'Mysql': SELECT testcase.date, testcase.dateID FROM testcase WHERE (testcase.dateID='6') === 2012-04-07 12:02:49,565 [-109] INFO DSResponse - [builtinApplication.testcase_add, builtinApplication.null] DSResponse: List with 1 items === 2012-04-07 12:02:49,565 [-109] INFO DSResponse - [builtinApplication.testcase_add] DSResponse: List with 1 items === 2012-04-07 12:02:49,565 [-109] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8 === 2012-04-07 12:02:49,565 [-109] DEBUG SQLTransaction - Committing Mysql transaction "29206269" === 2012-04-07 12:02:49,676 [-109] DEBUG RPCManager - non-DMI response, dropExtraFields: false === 2012-04-07 12:02:49,676 [-109] DEBUG SQLTransaction - Returning transactional connection for Mysql with hashcode "29206269" === 2012-04-07 12:02:49,676 [-109] DEBUG SQLTransaction - Ending Mysql transaction "29206269" === 2012-04-07 12:02:50,081 [-109] DEBUG SQLConnectionManager - About to close PoolableConnection with hashcode "29206269" === 2012-04-07 12:02:50,315 [-109] DEBUG SQLTransaction - Returning transactional connection for Mysql (connection is null) === 2012-04-07 12:02:50,315 [-109] INFO Compression - /plantillaIdeiak/sc/IDACall: 178 -> 162 bytes === 2012-04-07 12:02:50,612 [-109] INFO RequestContext - URL: '/plantillaIdeiak/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.3; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': MSIE with Accept-Encoding header, ready for compressed JS
[builtinApplication.testcase_add] Executing SQL update on 'Mysql': INSERT INTO testcase (date) VALUES ('2012-04-07 12:02:48')
Its inserting the date in GMT+2 which is my localtimezone.
So I think the problem is in the Mysql Insert Query Process.
Hope you could see the problem.
Thanks in advance,
Pablo
Comment
-
Dear Isomorphic,
I have read very deep all the docs and forum posts I have found about datetime and TimeZone settings on SmartGWT and therefore am I trying to understand the way the dates are stored in database.
With the last post I was trying to show you the date in GMT shown in the logs but you are correct, I have to set the attribute as date.
I have corrected the code this way:
Code:IButton createDate = new IButton("CREATE"); createDate.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub Record r = new Record(); Date d = new Date(); System.out.println("Date GMT: "+d.toGMTString()); r.setAttribute("date",d); DataSource.get("testcase").addData(r); } });
Here is the server log when I click the create date button:
Code:Date GMT: 7 Apr 2012 19:12:39 GMT === 2012-04-07 21:12:39,828 [-119] INFO RequestContext - URL: '/plantillaIdeiak/sc/IDACall', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.3; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': MSIE with Accept-Encoding header, ready for compressed JS === 2012-04-07 21:12:39,828 [-119] DEBUG XML - Parsed XML from (in memory stream): 0ms === 2012-04-07 21:12:39,859 [-117] INFO RequestContext - URL: '/plantillaIdeiak/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.3; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': MSIE with Accept-Encoding header, ready for compressed JS === 2012-04-07 21:12:39,875 [-119] DEBUG RPCManager - Processing 1 requests. === 2012-04-07 21:12:39,875 [-119] DEBUG RPCManager - Request #1 (DSRequest) payload: { values:{ date:new Date(1333825959000) }, operationConfig:{ dataSource:"testcase", operationType:"add" }, appID:"builtinApplication", operation:"testcase_add", oldValues:{ date:new Date(1333825959000) }, criteria:{ } } === 2012-04-07 21:12:39,875 [-119] INFO IDACall - Performing 1 operation(s) === 2012-04-07 21:12:39,875 [-119] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null === 2012-04-07 21:12:39,875 [-119] DEBUG DeclarativeSecurity - DataSource testcase is not in the pre-checked list, processing... === 2012-04-07 21:12:39,875 [-119] DEBUG AppBase - [builtinApplication.testcase_add] No userTypes defined, allowing anyone access to all operations for this application === 2012-04-07 21:12:39,875 [-119] DEBUG AppBase - [builtinApplication.testcase_add] No public zero-argument method named '_testcase_add' found, performing generic datasource operation === 2012-04-07 21:12:39,875 [-119] INFO SQLDataSource - [builtinApplication.testcase_add] Performing add operation with criteria: {date:new Date(1333825959000)} values: {date:new Date(1333825959000)} === 2012-04-07 21:12:39,875 [-119] DEBUG SQLValuesClause - [builtinApplication.testcase_add] Sequences: {dateID=__default} === 2012-04-07 21:12:40,233 [-119] DEBUG SQLConnectionManager - [builtinApplication.testcase_add] Returning borrowed connection '9119742' === 2012-04-07 21:12:40,343 [-119] DEBUG SQLTransaction - [builtinApplication.testcase_add] Started new Mysql transaction "9119742" === 2012-04-07 21:12:40,343 [-119] DEBUG SQLDriver - [builtinApplication.testcase_add] About to execute SQL update in 'Mysql' using connection'9119742' === 2012-04-07 21:12:40,343 [-119] INFO SQLDriver - [builtinApplication.testcase_add] Executing SQL update on 'Mysql': INSERT INTO testcase (date) VALUES ('2012-04-07 21:12:39') === 2012-04-07 21:12:40,561 [-119] DEBUG SQLDataSource - [builtinApplication.testcase_add] add operation affected 1 rows === 2012-04-07 21:12:40,577 [-119] DEBUG MysqlDriver - [builtinApplication.testcase_add] fetchLastRow data - primaryKeysPresent: {}sequencesNotPresent: [dateID] === 2012-04-07 21:12:40,577 [-119] DEBUG SQLDriver - [builtinApplication.testcase_add] About to execute SQL query in 'Mysql' using connection '9119742' === 2012-04-07 21:12:40,577 [-119] INFO SQLDriver - [builtinApplication.testcase_add] Executing SQL query on 'Mysql': SELECT LAST_INSERT_ID() === 2012-04-07 21:12:40,671 [-119] INFO SQLDataSource - [builtinApplication.testcase_add] primaryKeys: {dateID=7} === 2012-04-07 21:12:40,671 [-119] DEBUG DeclarativeSecurity - [builtinApplication.testcase_add] Processing security checks for DataSource null, field null === 2012-04-07 21:12:40,671 [-119] DEBUG DeclarativeSecurity - [builtinApplication.testcase_add] DataSource testcase is not in the pre-checked list, processing... === 2012-04-07 21:12:40,671 [-119] DEBUG AppBase - [builtinApplication.testcase_add, builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application === 2012-04-07 21:12:40,671 [-119] DEBUG AppBase - [builtinApplication.testcase_add, builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation === 2012-04-07 21:12:40,671 [-119] INFO SQLDataSource - [builtinApplication.testcase_add, builtinApplication.null] Performing fetch operation with criteria: {dateID:7} values: {dateID:7} === 2012-04-07 21:12:40,671 [-119] INFO SQLDataSource - [builtinApplication.testcase_add, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause === 2012-04-07 21:12:40,671 [-119] INFO SQLDataSource - [builtinApplication.testcase_add, builtinApplication.null] Executing SQL query on 'Mysql': SELECT testcase.date, testcase.dateID FROM testcase WHERE (testcase.dateID='7') === 2012-04-07 21:12:40,671 [-119] DEBUG SQLDriver - [builtinApplication.testcase_add, builtinApplication.null] About to execute SQL query in 'Mysql' using connection '9119742' === 2012-04-07 21:12:40,671 [-119] INFO SQLDriver - [builtinApplication.testcase_add, builtinApplication.null] Executing SQL query on 'Mysql': SELECT testcase.date, testcase.dateID FROM testcase WHERE (testcase.dateID='7') === 2012-04-07 21:12:41,014 [-119] INFO DSResponse - [builtinApplication.testcase_add, builtinApplication.null] DSResponse: List with 1 items === 2012-04-07 21:12:41,014 [-119] INFO DSResponse - [builtinApplication.testcase_add] DSResponse: List with 1 items === 2012-04-07 21:12:41,014 [-119] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8 === 2012-04-07 21:12:41,014 [-119] DEBUG SQLTransaction - Committing Mysql transaction "9119742" === 2012-04-07 21:12:41,124 [-119] DEBUG RPCManager - non-DMI response, dropExtraFields: false === 2012-04-07 21:12:41,124 [-119] DEBUG SQLTransaction - Returning transactional connection for Mysql with hashcode "9119742" === 2012-04-07 21:12:41,124 [-119] DEBUG SQLTransaction - Ending Mysql transaction "9119742" === 2012-04-07 21:12:41,217 [-119] DEBUG SQLConnectionManager - About to close PoolableConnection with hashcode "9119742" === 2012-04-07 21:12:41,326 [-119] DEBUG SQLTransaction - Returning transactional connection for Mysql (connection is null) === 2012-04-07 21:12:41,326 [-119] INFO Compression - /plantillaIdeiak/sc/IDACall: 178 -> 162 bytes === 2012-04-07 21:12:41,654 [-119] INFO RequestContext - URL: '/plantillaIdeiak/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.3; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': MSIE with Accept-Encoding header, ready for compressed JS
Date GMT: 7 Apr 2012 19:12:39 GMT
But as you can see, when the server sends the Insert Query to the MySQL server, the datetime is 2012-04-07 21:12:39 which is in local timezone (GMT+2).
[builtinApplication.testcase_add] Executing SQL update on 'Mysql': INSERT INTO testcase (date) VALUES ('2012-04-07 21:12:39')
I think you can understand my problem. The date is being stored not in GMT and I need it to be stored in GMT.
I dont know if its a bug or not, but in the previous post you wrote it was stored in GMT and I cant find this feature work as expected.
I have read all the docs in the previous weeks and I couldnt make it work so I decided to write you in the forum, so I hope you could help me find the problem, like previous times.
Thanks very much and looking forward your answer.
Pablo
Comment
-
One last time: a datetime value does not have a timezone. It is milliseconds since epoch hence not timezone-sensitive. It can then be *rendered* in a specific timezone. A time *String* which does not incorporate a timezone can also be *parsed* assuming it is in a particular timezone.
SmartGWT gets the correct value to the server as a Java Date object. No timezones are involved. We then form this SQL which does not have a timezone:
Code:INSERT INTO testcase (date) VALUES ('2012-04-07 21:12:39')
Comment
-
Hi isomorphic, have you reproduced the problem of the insert query I show you in the test case?
I have work around the problem and I think the problem is in the datasource adddata operation where builds the sql query when it generates the date value.
I am looking forward your answer and i hope we could find a solution to continue with the process.
Thanks for your effort,
Pablo
Comment
-
Originally posted by IsomorphicOne last time: a datetime value does not have a timezone. It is milliseconds since epoch hence not timezone-sensitive. It can then be *rendered* in a specific timezone. A time *String* which does not incorporate a timezone can also be *parsed* assuming it is in a particular timezone.
SmartGWT gets the correct value to the server as a Java Date object. No timezones are involved. We then form this SQL which does not have a timezone:
Code:INSERT INTO testcase (date) VALUES ('2012-04-07 21:12:39')
I think the problem is when you form the SQL before you send it to the MYSQL Server. As you said correctly it does not have a timezone, but the datetime has been applied a timezone before the query is formed.
The SQL query should be:
INSERT INTO testcase (date) VALUES ('2012-04-07 19:12:39')
instead of
INSERT INTO testcase (date) VALUES ('2012-04-07 21:12:39')
I hope you could see the problem and find how we could solve it.
Thanks in advance,
Pablo
Comment
-
Hi Isomorphic,
I have been working hard trying to send a date object on GMT in an SQL statement but I can not do it.
As the DateFormatAndStorage docs say about the time fields on datasources:
"When using the Smart GWT server framework, "time" values are automatically transmitted such that the resulting Date object has the same hour, minute and second values in local time, and year/month/day is ignored."
It is possible to have the resulting Date object on GMT time instead of local time, in order to force to use this time on the SQL statement.
I wish you could help me because I am really blocked at this point and I need to move on my project asap.
Thank you very much and if you need any more information, please let me know.
Best regards,
Pablo Ibañez
Comment
-
Hi Isomorphic,
Thank you very much for your quick response.
As you see in a previous post, I used the following code to store a date on my SQL database:
Code:IButton createDate = new IButton("CREATE"); createDate.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub Record r = new Record(); Date d = new Date(); System.out.println("Date GMT: "+d.toGMTString()); r.setAttribute("date",d); DataSource.get("testcase").addData(r); } });
When I check the Development Console , I see:
Code:Date GMT: 7 Apr 2012 19:12:39 GMT === 2012-04-07 21:12:39,828 [-119] INFO RequestContext - URL: '/plantillaIdeiak/sc/IDACall', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.3; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': MSIE with Accept-Encoding header, ready for compressed JS === 2012-04-07 21:12:39,828 [-119] DEBUG XML - Parsed XML from (in memory stream): 0ms === 2012-04-07 21:12:39,859 [-117] INFO RequestContext - URL: '/plantillaIdeiak/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.3; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': MSIE with Accept-Encoding header, ready for compressed JS === 2012-04-07 21:12:39,875 [-119] DEBUG RPCManager - Processing 1 requests. === 2012-04-07 21:12:39,875 [-119] DEBUG RPCManager - Request #1 (DSRequest) payload: { values:{ date:new Date(1333825959000) }, operationConfig:{ dataSource:"testcase", operationType:"add" }, appID:"builtinApplication", operation:"testcase_add", oldValues:{ date:new Date(1333825959000) }, criteria:{ } } === 2012-04-07 21:12:39,875 [-119] INFO IDACall - Performing 1 operation(s) === 2012-04-07 21:12:39,875 [-119] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null === 2012-04-07 21:12:39,875 [-119] DEBUG DeclarativeSecurity - DataSource testcase is not in the pre-checked list, processing... === 2012-04-07 21:12:39,875 [-119] DEBUG AppBase - [builtinApplication.testcase_add] No userTypes defined, allowing anyone access to all operations for this application === 2012-04-07 21:12:39,875 [-119] DEBUG AppBase - [builtinApplication.testcase_add] No public zero-argument method named '_testcase_add' found, performing generic datasource operation === 2012-04-07 21:12:39,875 [-119] INFO SQLDataSource - [builtinApplication.testcase_add] Performing add operation with criteria: {date:new Date(1333825959000)} values: {date:new Date(1333825959000)} === 2012-04-07 21:12:39,875 [-119] DEBUG SQLValuesClause - [builtinApplication.testcase_add] Sequences: {dateID=__default} === 2012-04-07 21:12:40,233 [-119] DEBUG SQLConnectionManager - [builtinApplication.testcase_add] Returning borrowed connection '9119742' === 2012-04-07 21:12:40,343 [-119] DEBUG SQLTransaction - [builtinApplication.testcase_add] Started new Mysql transaction "9119742" === 2012-04-07 21:12:40,343 [-119] DEBUG SQLDriver - [builtinApplication.testcase_add] About to execute SQL update in 'Mysql' using connection'9119742' === 2012-04-07 21:12:40,343 [-119] INFO SQLDriver - [builtinApplication.testcase_add] Executing SQL update on 'Mysql': INSERT INTO testcase (date) VALUES ('2012-04-07 21:12:39') === 2012-04-07 21:12:40,561 [-119] DEBUG SQLDataSource - [builtinApplication.testcase_add] add operation affected 1 rows === 2012-04-07 21:12:40,577 [-119] DEBUG MysqlDriver - [builtinApplication.testcase_add] fetchLastRow data - primaryKeysPresent: {}sequencesNotPresent: [dateID] === 2012-04-07 21:12:40,577 [-119] DEBUG SQLDriver - [builtinApplication.testcase_add] About to execute SQL query in 'Mysql' using connection '9119742' === 2012-04-07 21:12:40,577 [-119] INFO SQLDriver - [builtinApplication.testcase_add] Executing SQL query on 'Mysql': SELECT LAST_INSERT_ID() === 2012-04-07 21:12:40,671 [-119] INFO SQLDataSource - [builtinApplication.testcase_add] primaryKeys: {dateID=7} === 2012-04-07 21:12:40,671 [-119] DEBUG DeclarativeSecurity - [builtinApplication.testcase_add] Processing security checks for DataSource null, field null === 2012-04-07 21:12:40,671 [-119] DEBUG DeclarativeSecurity - [builtinApplication.testcase_add] DataSource testcase is not in the pre-checked list, processing... === 2012-04-07 21:12:40,671 [-119] DEBUG AppBase - [builtinApplication.testcase_add, builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application === 2012-04-07 21:12:40,671 [-119] DEBUG AppBase - [builtinApplication.testcase_add, builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation === 2012-04-07 21:12:40,671 [-119] INFO SQLDataSource - [builtinApplication.testcase_add, builtinApplication.null] Performing fetch operation with criteria: {dateID:7} values: {dateID:7} === 2012-04-07 21:12:40,671 [-119] INFO SQLDataSource - [builtinApplication.testcase_add, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause === 2012-04-07 21:12:40,671 [-119] INFO SQLDataSource - [builtinApplication.testcase_add, builtinApplication.null] Executing SQL query on 'Mysql': SELECT testcase.date, testcase.dateID FROM testcase WHERE (testcase.dateID='7') === 2012-04-07 21:12:40,671 [-119] DEBUG SQLDriver - [builtinApplication.testcase_add, builtinApplication.null] About to execute SQL query in 'Mysql' using connection '9119742' === 2012-04-07 21:12:40,671 [-119] INFO SQLDriver - [builtinApplication.testcase_add, builtinApplication.null] Executing SQL query on 'Mysql': SELECT testcase.date, testcase.dateID FROM testcase WHERE (testcase.dateID='7') === 2012-04-07 21:12:41,014 [-119] INFO DSResponse - [builtinApplication.testcase_add, builtinApplication.null] DSResponse: List with 1 items === 2012-04-07 21:12:41,014 [-119] INFO DSResponse - [builtinApplication.testcase_add] DSResponse: List with 1 items === 2012-04-07 21:12:41,014 [-119] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8 === 2012-04-07 21:12:41,014 [-119] DEBUG SQLTransaction - Committing Mysql transaction "9119742" === 2012-04-07 21:12:41,124 [-119] DEBUG RPCManager - non-DMI response, dropExtraFields: false === 2012-04-07 21:12:41,124 [-119] DEBUG SQLTransaction - Returning transactional connection for Mysql with hashcode "9119742" === 2012-04-07 21:12:41,124 [-119] DEBUG SQLTransaction - Ending Mysql transaction "9119742" === 2012-04-07 21:12:41,217 [-119] DEBUG SQLConnectionManager - About to close PoolableConnection with hashcode "9119742" === 2012-04-07 21:12:41,326 [-119] DEBUG SQLTransaction - Returning transactional connection for Mysql (connection is null) === 2012-04-07 21:12:41,326 [-119] INFO Compression - /plantillaIdeiak/sc/IDACall: 178 -> 162 bytes === 2012-04-07 21:12:41,654 [-119] INFO RequestContext - URL: '/plantillaIdeiak/sc/system/reference/skin/images/server_client_exchange.png', User-Agent: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; GTB7.3; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)': MSIE with Accept-Encoding header, ready for compressed JS
- The date in GMT from the instruction System.out.println("Date GMT: "+d.toGMTString()); shows:
Code:Date GMT: 7 Apr 2012 19:12:39 GMT
Code:=== 2012-04-07 21:12:40,343 [-119] INFO SQLDriver - [builtinApplication.testcase_add] Executing SQL update on 'Mysql': INSERT INTO testcase (date) VALUES ('2012-04-07 21:12:39')
As you see in previous posts, it appears to be that when the date object is casted to a data.sql object it uses the localtime timezone to cast the date.
Is that true, or maybe I am doing something wrong.
Would you please tell me if I am doing something wrong?
I am trying to have the same date on the SQL query as the date sent on the record.
Thank you very much and I am looking forward your answer.
Best regards,
PabloLast edited by paibanez; 26 Jun 2013, 06:11.
Comment
-
Hi Isomorphic,
Thank you very much for your response. I am really sorry because I have studied deeply the date storage guide and I can not find the clue.
If I run the test case I sent you on previous posts I can see that date object sent on the DSRequest is different than the date object created on the code. It looks like the system is creating the date object to send to the server from the original object but adding my local timezone difference.
Look at this code and its results:
Code:IButton createDate = new IButton("CREATE"); createDate.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // TODO Auto-generated method stub Record r = new Record(); Date d = new Date(); System.out.println("Date GMT: "+d.toGMTString()); System.out.println("Date time: "+d.getTime()); r.setAttribute("date",d); DataSource.get("testCase").addData(r); } });
Code:Date GMT: 27 Jun 2013 13:19:32 GMT Date time: 1372339172793 === 2013-06-27 15:19:33,010 [l0-6] INFO RequestContext - URL: '/plantillaIdeiak/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0': Moz (Gecko) with Accept-Encoding header === 2013-06-27 15:19:33,011 [l0-6] DEBUG IDACall - Header Name:Value pair: Host:127.0.0.1:8888 === 2013-06-27 15:19:33,011 [l0-6] DEBUG IDACall - Header Name:Value pair: User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0 === 2013-06-27 15:19:33,011 [l0-6] DEBUG IDACall - Header Name:Value pair: Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 === 2013-06-27 15:19:33,011 [l0-6] DEBUG IDACall - Header Name:Value pair: Accept-Language:es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3 === 2013-06-27 15:19:33,013 [l0-6] DEBUG IDACall - Header Name:Value pair: Accept-Encoding:gzip, deflate === 2013-06-27 15:19:33,013 [l0-6] DEBUG IDACall - Header Name:Value pair: Content-Type:application/x-www-form-urlencoded; charset=UTF-8 === 2013-06-27 15:19:33,013 [l0-6] DEBUG IDACall - Header Name:Value pair: Referer:http://127.0.0.1:8888/index2.html?gwt.codesvr=127.0.0.1:9997 === 2013-06-27 15:19:33,014 [l0-6] DEBUG IDACall - Header Name:Value pair: Content-Length:940 === 2013-06-27 15:19:33,014 [l0-6] DEBUG IDACall - Header Name:Value pair: Cookie:RSLoggedUser=pibanez%40telematika.es; isc_cState=ready; JSESSIONID=lfhauqvn4n6s === 2013-06-27 15:19:33,014 [l0-6] DEBUG IDACall - Header Name:Value pair: Connection:keep-alive === 2013-06-27 15:19:33,014 [l0-6] DEBUG IDACall - Header Name:Value pair: Pragma:no-cache === 2013-06-27 15:19:33,014 [l0-6] DEBUG IDACall - Header Name:Value pair: Cache-Control:no-cache === 2013-06-27 15:19:33,014 [l0-6] DEBUG IDACall - session exists: null === 2013-06-27 15:19:33,014 [l0-6] DEBUG IDACall - remote user: null === 2013-06-27 15:19:33,020 [l0-6] DEBUG XML - Parsed XML from (in memory stream): 3ms === 2013-06-27 15:19:33,029 [l0-6] DEBUG RPCManager - Processing 1 requests. === 2013-06-27 15:19:33,034 [l0-6] DEBUG RPCManager - Request #1 (DSRequest) payload: { values:{ date:new Date(1372339172000) }, operationConfig:{ dataSource:"testCase", operationType:"add" }, appID:"builtinApplication", operation:"testCase_add", oldValues:{ date:new Date(1372339172000) }, criteria:{ } } === 2013-06-27 15:19:33,035 [l0-6] INFO IDACall - Performing 1 operation(s) === 2013-06-27 15:19:33,035 [l0-6] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null === 2013-06-27 15:19:33,035 [l0-6] DEBUG DeclarativeSecurity - DataSource testCase is not in the pre-checked list, processing... === 2013-06-27 15:19:33,035 [l0-6] DEBUG AppBase - [builtinApplication.testCase_add] No userTypes defined, allowing anyone access to all operations for this application === 2013-06-27 15:19:33,036 [l0-6] DEBUG AppBase - [builtinApplication.testCase_add] No public zero-argument method named '_testCase_add' found, performing generic datasource operation === 2013-06-27 15:19:33,037 [l0-6] INFO SQLDataSource - [builtinApplication.testCase_add] Performing add operation with criteria: {date:new Date(1372339172000)} values: {date:new Date(1372339172000)} === 2013-06-27 15:19:33,041 [l0-6] DEBUG SQLValuesClause - [builtinApplication.testCase_add] Sequences: {dateID=__default} === 2013-06-27 15:19:33,046 [l0-6] DEBUG PoolableSQLConnectionFactory - [builtinApplication.testCase_add] Executing pingTest 'select 1 from dual' on connection 1852798579 === 2013-06-27 15:19:33,048 [l0-6] DEBUG SQLConnectionManager - [builtinApplication.testCase_add] Returning borrowed connection '1852798579' === 2013-06-27 15:19:33,049 [l0-6] DEBUG SQLTransaction - [builtinApplication.testCase_add] Started new Mysql transaction "1852798579" === 2013-06-27 15:19:33,049 [l0-6] DEBUG SQLDriver - [builtinApplication.testCase_add] About to execute SQL update in 'Mysql' using connection'1852798579' === 2013-06-27 15:19:33,049 [l0-6] INFO SQLDriver - [builtinApplication.testCase_add] Executing SQL update on 'Mysql': INSERT INTO testcase (date) VALUES ('2013-06-27 15:19:32') === 2013-06-27 15:19:33,143 [l0-6] DEBUG SQLDataSource - [builtinApplication.testCase_add] add operation affected 1 rows === 2013-06-27 15:19:33,144 [l0-6] DEBUG MysqlDriver - [builtinApplication.testCase_add] fetchLastRow data - primaryKeysPresent: {}sequencesNotPresent: [dateID] === 2013-06-27 15:19:33,145 [l0-6] DEBUG SQLDriver - [builtinApplication.testCase_add] About to execute SQL query in 'Mysql' using connection '1852798579' === 2013-06-27 15:19:33,145 [l0-6] INFO SQLDriver - [builtinApplication.testCase_add] Executing SQL query on 'Mysql': SELECT LAST_INSERT_ID() === 2013-06-27 15:19:33,147 [l0-6] INFO SQLDataSource - [builtinApplication.testCase_add] primaryKeys: {dateID=26} === 2013-06-27 15:19:33,147 [l0-6] DEBUG DeclarativeSecurity - [builtinApplication.testCase_add] Processing security checks for DataSource null, field null === 2013-06-27 15:19:33,148 [l0-6] DEBUG DeclarativeSecurity - [builtinApplication.testCase_add] DataSource testCase is not in the pre-checked list, processing... === 2013-06-27 15:19:33,148 [l0-6] DEBUG AppBase - [builtinApplication.testCase_add, builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application === 2013-06-27 15:19:33,149 [l0-6] DEBUG AppBase - [builtinApplication.testCase_add, builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation === 2013-06-27 15:19:33,150 [l0-6] INFO SQLDataSource - [builtinApplication.testCase_add, builtinApplication.null] Performing fetch operation with criteria: {dateID:26} values: {dateID:26} === 2013-06-27 15:19:33,150 [l0-6] INFO SQLDataSource - [builtinApplication.testCase_add, builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause === 2013-06-27 15:19:33,152 [l0-6] INFO SQLDataSource - [builtinApplication.testCase_add, builtinApplication.null] Executing SQL query on 'Mysql': SELECT testcase.date, testcase.dateID FROM testcase WHERE (testcase.dateID=26) === 2013-06-27 15:19:33,152 [l0-6] DEBUG SQLDriver - [builtinApplication.testCase_add, builtinApplication.null] About to execute SQL query in 'Mysql' using connection '1852798579' === 2013-06-27 15:19:33,152 [l0-6] INFO SQLDriver - [builtinApplication.testCase_add, builtinApplication.null] Executing SQL query on 'Mysql': SELECT testcase.date, testcase.dateID FROM testcase WHERE (testcase.dateID=26) === 2013-06-27 15:19:33,155 [l0-6] INFO DSResponse - [builtinApplication.testCase_add, builtinApplication.null] DSResponse: List with 1 items === 2013-06-27 15:19:33,156 [l0-6] INFO DSResponse - [builtinApplication.testCase_add] DSResponse: List with 1 items === 2013-06-27 15:19:33,156 [l0-6] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8 === 2013-06-27 15:19:33,156 [l0-6] DEBUG SQLTransaction - Committing Mysql transaction "1852798579" === 2013-06-27 15:19:33,160 [l0-6] DEBUG RPCManager - non-DMI response, dropExtraFields: false === 2013-06-27 15:19:33,161 [l0-6] DEBUG SQLTransaction - Returning transactional connection for Mysql with hashcode "1852798579" === 2013-06-27 15:19:33,161 [l0-6] DEBUG SQLTransaction - Ending Mysql transaction "1852798579" === 2013-06-27 15:19:33,164 [l0-6] DEBUG SQLConnectionManager - About to close PoolableConnection with hashcode "1852798579" === 2013-06-27 15:19:33,164 [l0-6] DEBUG PoolableSQLConnectionFactory - Executing pingTest 'select 1 from dual' on connection 1852798579 === 2013-06-27 15:19:33,165 [l0-6] DEBUG SQLTransaction - Returning transactional connection for Mysql (connection is null) === 2013-06-27 15:19:33,166 [l0-6] INFO Compression - /plantillaIdeiak/sc/IDACall: 179 -> 163 bytes
- The getTime method on the original date object returns a value different than the one sent on the DSRequest:
Original date:
Code:Date GMT: 27 Jun 2013 13:19:32 GMT Date time: 1372339172793
Code:=== 2013-06-27 15:19:33,020 [l0-6] DEBUG XML - Parsed XML from (in memory stream): 3ms === 2013-06-27 15:19:33,029 [l0-6] DEBUG RPCManager - Processing 1 requests. === 2013-06-27 15:19:33,034 [l0-6] DEBUG RPCManager - Request #1 (DSRequest) payload: { values:{ date:new Date(1372339172000) }, operationConfig:{ dataSource:"testCase", operationType:"add" }, appID:"builtinApplication", operation:"testCase_add", oldValues:{ date:new Date(1372339172000) }, criteria:{ } }
"When using the Smart GWT server framework, "datetime" values are automatically transmitted such that the resulting Date object has the same GMT/UTC timestamp (milliseconds since epoch)."
But as I understand on the results I am watching that the date object sent on the DSRequest is different than the original Date object. It looks like the setattribute method of the record is creating a new Date object different from the original Date object (adding the Timezone difference).
I have tried the different formatters (Date.setShortDatetimeDisplayFormat and Date.setNormalDatetimeDisplayFormat) but it does not make any effect on the results. I can think these display formatters are only used to display the dates on SGWT components, such as Dynamic Forms or ListGrids. Is that correct??
I wish you could tell me the clue because really It is driving me crazy and I can not find what I am doing wrong.
Thank you very much and I hope we could finish with these posts soon ;)
Best regards,
PabloLast edited by paibanez; 27 Jun 2013, 05:49.
Comment
Comment