final String dtFormat = "dd MMM yyyy hh:mm a";
when(config.getProperty(CoreConstants.STRING_TO_DATE_FORMATS))
.thenReturn(dtFormat);
ConfigContext.overrideConfig(Thread.currentThread()
.getContextClassLoader(), config);
DateTimeService dtSvc = mock(DateTimeService.class);
SimpleDateFormat sdf = new SimpleDateFormat(dtFormat);
when(dtSvc.toDateTimeString(date)).thenReturn(sdf.format(date));
attributeValueReader.setDateTimeService(dtSvc);
// create allowed formats
List<String> allowedFormats = new ArrayList<String>();
allowedFormats.add(dtFormat);
allowedFormats.add("d MMM yyyy hh:mm a");