Hi,
I'm currently using SmartGWT 4.1p.
(SmartClient Version: v9.1p_2014-03-16/PowerEdition Deployment (built 2014-03-16))
I'm having some issues with the FilterBuilder and DateTime.
When I try to filter on a DateTime, the criteria generated by the FilterBuilder does not contains the time.
Here is the code,
First my date parsers
The code to create the FilterBuilder
Test case 1: Date
Filter on the "date" column equals ''24 Mar 2014"
The criteria is
Test case 2: Date Time
Filter on the "datetime" column equals ''24 Mar 2014 - 09:10:11"
The criteria is
I do not know why I don't have the hour and the minute.
How can I retrieve the correct time in the criteria?
Test case 3: Time
Filter on the "time" column equals 10:20"
The criteria is
I do not have the time, only the default date..
What do I do wrong?
Regards
Julien
I'm currently using SmartGWT 4.1p.
(SmartClient Version: v9.1p_2014-03-16/PowerEdition Deployment (built 2014-03-16))
I'm having some issues with the FilterBuilder and DateTime.
When I try to filter on a DateTime, the criteria generated by the FilterBuilder does not contains the time.
Here is the code,
First my date parsers
Code:
DateUtil.setNormalDatetimeDisplayFormatter(new DateDisplayFormatter() { public String format(Date date) { return Localization.formatDateTime(date); } }); DateUtil.setNormalDateDisplayFormatter(new DateDisplayFormatter() { public String format(Date date) { return Localization.formatDate(date); } }); DateUtil.setNormalTimeDisplayFormatter(new DateDisplayFormatter() { public String format(Date date) { return Localization.formatTime(date); } }); DateUtil.setShortDatetimeDisplayFormatter(new DateDisplayFormatter() { public String format(Date date) { return Localization.formatDateTime(date); } }); DateUtil.setShortDateDisplayFormatter(new DateDisplayFormatter() { public String format(Date date) { return Localization.formatDate(date); } }); DateUtil.setShortTimeDisplayFormatter(new DateDisplayFormatter() { public String format(Date date) { return Localization.formatTime(date); } }); DateUtil.setDateParser(new DateParser() { public Date parse(String dateString) { if ((dateString == null) || (dateString.length() < 8)) return null; if (dateString.length() > 11) return parseDateTime(dateString); if (dateString.charAt(2) == ':') return parseTime(dateString); return parseDate(dateString); } });
Code:
//Initialises date parsers with DateUtil Localization.init(); //Creates DataSource final DataSource dataSource = new DataSource(); dataSource.setFields(new DataSourceField("date", FieldType.DATE)); dataSource.setFields(new DataSourceField("time", FieldType.TIME)); dataSource.setFields(new DataSourceField("datetime", FieldType.DATETIME)); dataSource.setFields(new DataSourceField("creator", FieldType.CREATORTIMESTAMP)); dataSource.setFields(new DataSourceField("modifier", FieldType.MODIFIERTIMESTAMP)); //Creates the FilterBuilder final FilterBuilder filterBuilder = new FilterBuilder(); filterBuilder.setDataSource(dataSource); VLayout test = new VLayout(); test.setWidth(600); test.setHeight(400); test.addMember(filterBuilder); Button button = new Button("Do"); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Criteria criteria = filterBuilder.getCriteria(); String jsonCriteria = criteria == null? null : JSON.encode(criteria.getJsObj(), new JSONEncoder()); System.out.println(jsonCriteria); } }); test.addMember(button);
Filter on the "date" column equals ''24 Mar 2014"
The criteria is
Code:
{ "_constructor":"AdvancedCriteria", "operator":"and", "criteria":[ { "fieldName":"date", "operator":"equals", "value":"2014-03-24" } ] }
Test case 2: Date Time
Filter on the "datetime" column equals ''24 Mar 2014 - 09:10:11"
The criteria is
Code:
{ "_constructor":"AdvancedCriteria", "operator":"and", "criteria":[ { "fieldName":"datetime", "operator":"equals", "value":"2014-03-23T23:00:11.000" } ] }
How can I retrieve the correct time in the criteria?
Test case 3: Time
Filter on the "time" column equals 10:20"
The criteria is
Code:
{ "_constructor":"AdvancedCriteria", "operator":"and", "criteria":[ { "fieldName":"time", "operator":"equals", "value":"1970-01-01" } ] }
What do I do wrong?
Regards
Julien
Comment