ZipkinDependenciesJob { static long parseDay(String formattedDate) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); df.setTimeZone(TimeZone.getTimeZone("UTC")); try { return df.parse(formattedDate).getTime(); } catch (ParseException e) { throw new IllegalArgumentException( "First argument must be a yyyy-MM-dd formatted date. Ex. 2016-07-16"); } }  static void main(String[] args);  }
@Test public void parseDate() { TimeZone.setDefault(TimeZone.getTimeZone("UTC")); long date = ZipkinDependenciesJob.parseDay("2013-05-15"); assertThat(new Date(date)) .hasYear(2013) .hasMonth(5) .hasDayOfMonth(15) .hasHourOfDay(0) .hasMinute(0) .hasSecond(0) .hasMillisecond(0); }
@Test(expected = IllegalArgumentException.class) public void parseDate_malformed() { ZipkinDependenciesJob.parseDay("2013/05/15"); }