- public static Date parseLedgerDate(String dateString) {
- try {
- return ledgerDateFormatter.parse(dateString);
+ public static SimpleDate parseLedgerDate(String dateString) throws ParseException {
+ Matcher m = reLedgerDate.matcher(dateString);
+ if (!m.matches()) throw new ParseException(
+ String.format("'%s' does not match expected pattern '%s'", dateString,
+ reLedgerDate.toString()), 0);
+
+ String yearStr = m.group(1);
+ String monthStr = m.group(2);
+ String dayStr = m.group(3);
+
+ int year, month, day;
+
+ String toParse;
+ if (yearStr == null) {
+ SimpleDate today = SimpleDate.today();
+ year = today.year;
+ if (monthStr == null) {
+ month = today.month;
+ }
+ else month = Integer.parseInt(monthStr);