### Question:
DatePartitioner extends AbstractPartitioner { @Override public String getPartition() { return f.format(new Date()); } DatePartitioner(String format); @Override String getPartition(); @Override Date getRefresh();  }### Answer:
@Test public void testDatePartitionerGetPartition(){ DatePartitioner d = new DatePartitioner("yy/MM/dd"); String year = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)).substring(2); String month = Integer.toString(Calendar.getInstance().get(Calendar.MONTH)+1); String day = Integer.toString(Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); if(day.length() == 1){ day = "0"+day; } assertEquals(year+"/"+month+"/"+day,d.getPartition()); }
@Test public void testDatePartitionerGetPartition2(){ DatePartitioner d = new DatePartitioner("yyyy/MM/dd/HH/mm/ss"); String year = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); String month = Integer.toString(Calendar.getInstance().get(Calendar.MONTH)+1); String day = Integer.toString(Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); if(day.length() == 1){ day = "0"+day; } String hour = Integer.toString(Calendar.getInstance().get(Calendar.HOUR_OF_DAY)); if(hour.length() == 1){ hour = "0"+hour; } String min = Integer.toString(Calendar.getInstance().get(Calendar.MINUTE)); if(min.length() == 1){ min = "0"+min; } String sec = Integer.toString(Calendar.getInstance().get(Calendar.SECOND)); if(sec.length() == 1){ sec = "0"+sec; } assertEquals(year+"/"+month+"/"+day+"/"+hour+"/"+min+"/"+sec,d.getPartition()); }