EntityLog failed if there is no formatter for date. #PL-2244

This commit is contained in:
Konstantin Krivopustov 2013-09-23 11:35:23 +00:00
parent 90db824ae1
commit 53db6ab82c
2 changed files with 7 additions and 6 deletions

View File

@ -4,6 +4,7 @@
*/
package com.haulmont.cuba.security.app;
import com.haulmont.chile.core.datatypes.Datatype;
import com.haulmont.chile.core.datatypes.Datatypes;
import com.haulmont.chile.core.model.Instance;
import com.haulmont.chile.core.model.MetaClass;
@ -58,7 +59,7 @@ public class EntityLog implements EntityLogAPI {
protected Metadata metadata;
@Inject
private UserSessionSource userSessionSource;
protected UserSessionSource userSessionSource;
@Inject
public EntityLog(Configuration configuration) {
@ -324,15 +325,15 @@ public class EntityLog implements EntityLogAPI {
}
}
private String stringify(Object value) {
protected String stringify(Object value) {
if (value == null)
return "";
else if (value instanceof Instance) {
return ((Instance) value).getInstanceName();
} else if (value instanceof Date) {
SimpleDateFormat df = new SimpleDateFormat(
Datatypes.getFormatStrings(userSessionSource.getLocale()).getDateTimeFormat());
return df.format(value);
Datatype datatype = Datatypes.getNN(value.getClass());
//noinspection unchecked
return datatype.format(value);
} else if (value instanceof Iterable) {
StringBuilder sb = new StringBuilder();
sb.append("[");

View File

@ -22,7 +22,7 @@
<datatype class="com.haulmont.chile.core.datatypes.impl.StringDatatype"/>
<datatype class="com.haulmont.chile.core.datatypes.impl.DateTimeDatatype"
format="yyyy-MM-dd'T'HH:mm:ss.SSS"/>
format="yyyy-MM-dd HH:mm:ss.SSS"/>
<datatype class="com.haulmont.chile.core.datatypes.impl.DateDatatype"
format="yyyy-MM-dd"/>