AsyncRetrieveMessageFormat implements FormatTS { @Override public Object parse(String data) { if (data!=null && data.length()>0) { String[] items = data.split(getSeparator()); return new AsyncRetrieveMessage((Date)dateFormat.parse(items[0]), items[1], items[2]); } return null; }  String getSeparator(); void setSeparator(String separator); FormatTS getDateFormat(); void setDateFormat(FormatTS dateFormat); @Override String formatObject(Object item); @Override Object parse(String data);  }
@Test public void parse() { Object item = msgFormat.parse("20121110090807:1234:fred"); Assert.assertNotNull(item); Assert.assertTrue(item instanceof AsyncRetrieveMessage); AsyncRetrieveMessage msg = (AsyncRetrieveMessage)item; Assert.assertEquals("1234", msg.getPatientId()); Assert.assertEquals("fred", msg.getPatientName()); assertDateEquals(msg.getDate(), 2012, 10, 10, 9, 8, 7); }