@Test public void fromString() { DateClass dateClass = new DateClass(); dateClass.setDateFormat("MMMM yyyy"); when(localizationContext.getCurrentLocale()).thenReturn(new Locale("ro")); BaseProperty property = dateClass.fromString("octombrie 2015"); Date date = (Date) property.getValue(); assertEquals("10 2015", new SimpleDateFormat("MM yyyy").format(date)); }
@Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); if (StringUtils.isEmpty(value)) { if (getEmptyIsToday() == 1) { property.setValue(new Date()); } return property; } try { SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat(), getCurrentLocale()); property.setValue(sdf.parse(value)); return property; } catch (ParseException e) { return null; } }
DateClass extends PropertyClass { @Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); if (StringUtils.isEmpty(value)) { if (getEmptyIsToday() == 1) { property.setValue(new Date()); } return property; } try { SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat(), getCurrentLocale()); property.setValue(sdf.parse(value)); return property; } catch (ParseException e) { return null; } } }
DateClass extends PropertyClass { @Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); if (StringUtils.isEmpty(value)) { if (getEmptyIsToday() == 1) { property.setValue(new Date()); } return property; } try { SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat(), getCurrentLocale()); property.setValue(sdf.parse(value)); return property; } catch (ParseException e) { return null; } } DateClass(PropertyMetaClass metaClass);  DateClass(); }
DateClass extends PropertyClass { @Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); if (StringUtils.isEmpty(value)) { if (getEmptyIsToday() == 1) { property.setValue(new Date()); } return property; } try { SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat(), getCurrentLocale()); property.setValue(sdf.parse(value)); return property; } catch (ParseException e) { return null; } } DateClass(PropertyMetaClass metaClass);  DateClass(); int getPicker(); void setPicker(int picker); int getSize(); void setSize(int size); int getEmptyIsToday(); void setEmptyIsToday(int emptyIsToday); String getDateFormat(); void setDateFormat(String format); @Override BaseProperty fromString(String value); @Override BaseProperty newProperty(); String toFormString(BaseProperty property); @Override BaseProperty newPropertyfromXML(Element element); }
DateClass extends PropertyClass { @Override public BaseProperty fromString(String value) { BaseProperty property = newProperty(); if (StringUtils.isEmpty(value)) { if (getEmptyIsToday() == 1) { property.setValue(new Date()); } return property; } try { SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat(), getCurrentLocale()); property.setValue(sdf.parse(value)); return property; } catch (ParseException e) { return null; } } DateClass(PropertyMetaClass metaClass);  DateClass(); int getPicker(); void setPicker(int picker); int getSize(); void setSize(int size); int getEmptyIsToday(); void setEmptyIsToday(int emptyIsToday); String getDateFormat(); void setDateFormat(String format); @Override BaseProperty fromString(String value); @Override BaseProperty newProperty(); String toFormString(BaseProperty property); @Override BaseProperty newPropertyfromXML(Element element);  }