### Question:
DateOrDatetimeEditor extends PropertyEditorSupport { @Override public String getAsText() { Date date = (Date) getValue(); if (date == null) { return ""; } if ("0000".equals(new SimpleDateFormat("HmsS").format(date))) { return Context.getDateFormat().format(date); } else { return Context.getDateTimeFormat().format(date); } }  @Override void setAsText(String asString); @Override String getAsText();  }### Answer:
@Test public void getAsText_shouldPrintDateWithoutTime() throws ParseException { ed.setValue(ymdhm.parse("2011-10-27 00:00")); Assert.assertEquals("27/10/2011", ed.getAsText()); }
@Test public void getAsText_shouldPrintDateAndTimeWithTime() throws ParseException { ed.setValue(ymdhm.parse("2011-10-27 17:59")); Assert.assertEquals("27/10/2011 17:59", ed.getAsText()); }
@Test public void getAsText_shouldPrintDateWithoutTime() throws Exception { ed.setValue(ymdhm.parse("2011-10-27 00:00")); Assert.assertEquals("27/10/2011", ed.getAsText()); }
@Test public void getAsText_shouldPrintDateAndTimeWithTime() throws Exception { ed.setValue(ymdhm.parse("2011-10-27 17:59")); Assert.assertEquals("27/10/2011 17:59", ed.getAsText()); }