Hi,
I've got some questions about date format handling.
question 1:
Should the DateUtil.setNormalDateDisplayFormatter and DateUtil.setShortDateDisplayFormatter work on datetime typed items too ? I'm trying to set the date display and date input formats to common european dot-separated formats ("dd.MM.yyyy HH:mm"). It seems that if I'm using DateTimeItems on forms and/or DataSourceDateTimeFields in data sources the display formats set by DateUtil just don't seem to apply.
My observations:
a) ListGrid + data source with DataSourceDateTimeField: does not work (uses always TOEUROPEANSHORTDATETIME instead of calling my custom formatter).
b) ListGrid + data source with DataSourceDateField: works
c) DynamicForm + DateItem + data source with DataSourceDateField: works
d) DynamicForm + DateItem + data source with DataSourceDateTimeField: works
e) DynamicForm + DateTimeItem + data source with DataSourceDateField: does not work (uses always TOEUROPEANSHORTDATETIME instead of calling my custom formatter).
f) DynamicForm + DateTimeItem + data source with DataSourceDateTimeField: does not work (uses always TOEUROPEANSHORTDATETIME instead of calling my custom formatter).
Sorry if these a bit hard to get a grip on but I couldn't get my head on the logic here. It seems like in case of ListGrids the data source field type is the factor here and with forms the the actual form items affect the behaviour.
question 2:
I'm calling DateUtil.setDefaultDisplayTimezone("00:00") to set the time zone to my liking. Strangely this time zone gets only applied to the smartgwt's default datedisplayformats (available in DateDisplayFormat enum). If I use a custom format as set as above (see question 1) it seems the time zone does not get applied. This leads to the incorrect times by three hours as the browser's (+3h) time zone gets applied.
I'm using XML-based restdatasources and passing the dates as follows:
...
<somedatetime>2010-04-11T17:33:06</somedatetime>
...
What I really would like to do is to trust the server's time zone. What I mean above as I say time zone does not get applied I mean that when the server returns the 2010-04-11 17:33:06 date time the widgets render the time as 2010-04-11 20:33:06 (off by three hours). This does not happen if I don't set the custom formatter and use the default formats smartgwt sets up for me.
I'm using smartgwt 2.1/lgpl, gwt-mac-2.0.3 and safari 4.0.5 for my testing. I've initialized the date formats as follows:
I've got some questions about date format handling.
question 1:
Should the DateUtil.setNormalDateDisplayFormatter and DateUtil.setShortDateDisplayFormatter work on datetime typed items too ? I'm trying to set the date display and date input formats to common european dot-separated formats ("dd.MM.yyyy HH:mm"). It seems that if I'm using DateTimeItems on forms and/or DataSourceDateTimeFields in data sources the display formats set by DateUtil just don't seem to apply.
My observations:
a) ListGrid + data source with DataSourceDateTimeField: does not work (uses always TOEUROPEANSHORTDATETIME instead of calling my custom formatter).
b) ListGrid + data source with DataSourceDateField: works
c) DynamicForm + DateItem + data source with DataSourceDateField: works
d) DynamicForm + DateItem + data source with DataSourceDateTimeField: works
e) DynamicForm + DateTimeItem + data source with DataSourceDateField: does not work (uses always TOEUROPEANSHORTDATETIME instead of calling my custom formatter).
f) DynamicForm + DateTimeItem + data source with DataSourceDateTimeField: does not work (uses always TOEUROPEANSHORTDATETIME instead of calling my custom formatter).
Sorry if these a bit hard to get a grip on but I couldn't get my head on the logic here. It seems like in case of ListGrids the data source field type is the factor here and with forms the the actual form items affect the behaviour.
question 2:
I'm calling DateUtil.setDefaultDisplayTimezone("00:00") to set the time zone to my liking. Strangely this time zone gets only applied to the smartgwt's default datedisplayformats (available in DateDisplayFormat enum). If I use a custom format as set as above (see question 1) it seems the time zone does not get applied. This leads to the incorrect times by three hours as the browser's (+3h) time zone gets applied.
I'm using XML-based restdatasources and passing the dates as follows:
...
<somedatetime>2010-04-11T17:33:06</somedatetime>
...
What I really would like to do is to trust the server's time zone. What I mean above as I say time zone does not get applied I mean that when the server returns the 2010-04-11 17:33:06 date time the widgets render the time as 2010-04-11 20:33:06 (off by three hours). This does not happen if I don't set the custom formatter and use the default formats smartgwt sets up for me.
I'm using smartgwt 2.1/lgpl, gwt-mac-2.0.3 and safari 4.0.5 for my testing. I've initialized the date formats as follows:
Code:
private static DateTimeFormat dateFormat = DateTimeFormat.getFormat("dd.MM.yyyy HH:mm"); private static DateDisplayFormatter dateDisplayFormatter = new DateDisplayFormatter() { public String format(Date date) { if (date == null) return null; return dateFormat.format(date); } }; private static DateInputFormatter dateInputFormatter = new DateInputFormatter() { public Date parse(String s) { if (s == null) return null; return dateFormat.parse(s); } }; public void onModuleLoad() { DateUtil.setDefaultDisplayTimezone("00:00"); // Set up date formats globally DateUtil.setShortDateDisplayFormatter(dateDisplayFormatter); DateUtil.setNormalDateDisplayFormatter(dateDisplayFormatter); DateUtil.setDateInputFormatter(dateInputFormatter); //... }
Comment