@Test
public void testDecode() throws Exception {

    DateTimeStringCodec codec = new DateTimeStringCodec();
    codec.setFormat("MMddyyyy");
    Date dt1 = codec.decode(new byte[] { 0x31, 0x30, 0x31, 0x39, 0x32, 0x30, 0x31, 0x33 }, 8);
    codec.setFormat("(HHmmssyyyyMMdd)");
    Date dt2 = codec.decode("(18462820080604)".getBytes(), 16);
    Calendar cal = Calendar.getInstance();
    // 1
    cal.setTime(dt1);
    Assert.assertEquals(2013, cal.get(Calendar.YEAR), 0);
    Assert.assertEquals(10, cal.get(Calendar.MONTH) + 1, 0);
    Assert.assertEquals(19, cal.get(Calendar.DATE), 0);
    // 2
    cal.setTime(dt2);
    Assert.assertEquals(2008, cal.get(Calendar.YEAR), 0);
    Assert.assertEquals(6, cal.get(Calendar.MONTH) + 1, 0);
    Assert.assertEquals(4, cal.get(Calendar.DATE), 0);
    Assert.assertEquals(18, cal.get(Calendar.HOUR_OF_DAY), 0);
    Assert.assertEquals(46, cal.get(Calendar.MINUTE), 0);
    Assert.assertEquals(28, cal.get(Calendar.SECOND), 0);
    // Null Value
    codec.setFormat("MMddyyyy");
    codec.setNullByte("00");
    codec.setNullable("y");
    Assert.assertEquals(null, codec.decode(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 8));
}