+ String toParse;
+ if (year == null) {
+ Calendar now = Calendar.getInstance();
+ int thisYear = now.get(Calendar.YEAR);
+ if (month == null) {
+ int thisMonth = now.get(Calendar.MONTH) + 1;
+ toParse = String.format(Locale.US, "%04d/%02d/%s", thisYear, thisMonth, dateString);
+ }
+ else toParse = String.format(Locale.US, "%04d/%s", thisYear, dateString);
+ }
+ else toParse = dateString;
+
+ return dateFormatter.get().parse(toParse);
+ }
+ public static Calendar parseLedgerDateAsCalendar(String dateString) throws ParseException {
+ Date date = parseLedgerDate(dateString);
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ return calendar;
+ }
+ public static Date parseIsoDate(String dateString) throws ParseException {
+ return isoDateFormatter.get().parse(dateString);
+ }
+ public static String formatLedgerDate(Date date) {
+ return dateFormatter.get().format(date);
+ }
+ public static String formatIsoDate(Date date) {
+ return isoDateFormatter.get().format(date);
+ }