Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

JSONEncoder.encodeDate override does not work

$
0
0
I try to override the format used by datetime field in the FilterBuilder.
Code:

final JSONEncoder settings = new JSONEncoder(){
                                        @Override
                                        public String encodeDate(java.util.Date theDate){
                                                String date= DateTimeFormat.getFormat("yyyy/MM/dd").format(theDate);
                                                System.out.println("Date:" + date);
                                                return date;
                                               
                                        }
                                };

System.out.println("Before:" + this.filterBuilder.getCriteria().toJSON());
                                //settings.setDateFormat( JSONDateFormat.DATE_CONSTRUCTOR );
                                final String s = JSON.encode( this.filterBuilder.getCriteria().getJsObj(), settings );
                                System.out.println("After:" + s);

Here's the output:
Before:{
"_constructor":"AdvancedCriteria",
"operator":"and",
"criteria":[
{
"fieldName":"installation_date",
"operator":"equals",
"value":"2015-02-20"
}
]
}
After:{
"_constructor":"AdvancedCriteria",
"operator":"and",
"criteria":[
{
"fieldName":"installation_date",
"operator":"equals",
"value":"2015-02-20"
}
]
}

I expected to see the "value" in the format "yyyy/MM/dd" but it just JSONDateFormat.XML_SCHEMA

How to I override the data format for the JSONEncoder ?
The used version is old one:
SmartClient Version: v9.0p_2014-04-23/PowerEdition Deployment (built 2014-04-23)

Viewing all articles
Browse latest Browse all 4756

Trending Articles