DateParser { public static CSLDate toDate(String dateString) { return new CSLDateBuilder().raw(dateString).build(); }  static CSLDate toDate(String dateString); static CSLDate toDate(String year, String month); static CSLDate toDateRange(String year, String month); static CSLDate toDateSingle(String year, String month); static int toMonth(String month);  }
@Test public void toDate() { CSLDate d = DateParser.toDate("2013", "Aug"); assertArrayEquals(new int[][] { new int[] { 2013, 8 } }, d.getDateParts()); d = DateParser.toDate("2013", "Mar-Aug"); assertArrayEquals(new int[][] { new int[] { 2013, 3 }, new int[] { 2013, 8 } }, d.getDateParts()); d = DateParser.toDate("2013", "March-Aug"); assertArrayEquals(new int[][] { new int[] { 2013, 3 }, new int[] { 2013, 8 } }, d.getDateParts()); d = DateParser.toDate("2013", "Jan--Aug"); assertArrayEquals(new int[][] { new int[] { 2013, 1 }, new int[] { 2013, 8 } }, d.getDateParts()); d = DateParser.toDate("2000-2013", null); assertArrayEquals(new int[][] { new int[] { 2000 }, new int[] { 2013 } }, d.getDateParts()); d = DateParser.toDate("2000-2013", "Jan"); assertArrayEquals(new int[][] { new int[] { 2000 }, new int[] { 2013 } }, d.getDateParts()); d = DateParser.toDate("2000-bla", "Jan"); assertArrayEquals(new int[][] { new int[] { 2000 } }, d.getDateParts()); }
@Test public void toDateSlash() { CSLDate d = DateParser.toDate("2013", "Jul/Aug"); assertArrayEquals(new int[][] { new int[] { 2013, 7 }, new int[] { 2013, 8 } }, d.getDateParts()); d = DateParser.toDate("2013", "Jan/Aug"); assertArrayEquals(new int[][] { new int[] { 2013 } }, d.getDateParts()); d = DateParser.toDate("2013/2014", "Jan/Aug"); assertArrayEquals(new int[][] { new int[] { 2013 }, new int[] { 2014 } }, d.getDateParts()); }