@Test public void testTestDateFromat() { Date now = new Date(); Date date = (Date) converter.convert("now"); assertEquals(getCalFiled(now, Calendar.YEAR), getCalFiled(date, Calendar.YEAR)); assertEquals(getCalFiled(now, Calendar.MONTH), getCalFiled(date, Calendar.MONTH)); assertEquals(getCalFiled(now, Calendar.DAY_OF_MONTH), getCalFiled(date, Calendar.DAY_OF_MONTH)); date = (Date) converter.convert("Friday, September 8, 2017"); assertEquals(2017, getCalFiled(date, Calendar.YEAR)); assertEquals(Calendar.SEPTEMBER, getCalFiled(date, Calendar.MONTH)); assertEquals(8, getCalFiled(date, Calendar.DAY_OF_MONTH)); }
@Override public Date convert(String source) { List<DateGroup> groups = dateParser.parse(source); if (groups.size() > 0 && groups.get(0).getDates().size() > 0) { return groups.get(0).getDates().get(0); } throw new ConverterException("can not convert '" + source + "' to java.util.Date"); }
StringToDateConverter extends AbstractGenericConverter<String, Date> { @Override public Date convert(String source) { List<DateGroup> groups = dateParser.parse(source); if (groups.size() > 0 && groups.get(0).getDates().size() > 0) { return groups.get(0).getDates().get(0); } throw new ConverterException("can not convert '" + source + "' to java.util.Date"); } }
StringToDateConverter extends AbstractGenericConverter<String, Date> { @Override public Date convert(String source) { List<DateGroup> groups = dateParser.parse(source); if (groups.size() > 0 && groups.get(0).getDates().size() > 0) { return groups.get(0).getDates().get(0); } throw new ConverterException("can not convert '" + source + "' to java.util.Date"); }  }
StringToDateConverter extends AbstractGenericConverter<String, Date> { @Override public Date convert(String source) { List<DateGroup> groups = dateParser.parse(source); if (groups.size() > 0 && groups.get(0).getDates().size() > 0) { return groups.get(0).getDates().get(0); } throw new ConverterException("can not convert '" + source + "' to java.util.Date"); }  @Override Date convert(String source); }
StringToDateConverter extends AbstractGenericConverter<String, Date> { @Override public Date convert(String source) { List<DateGroup> groups = dateParser.parse(source); if (groups.size() > 0 && groups.get(0).getDates().size() > 0) { return groups.get(0).getDates().get(0); } throw new ConverterException("can not convert '" + source + "' to java.util.Date"); }  @Override Date convert(String source);  }