+ public static String[] monthNames;
+ public static String developerEmail = "dam+mole-crash@ktnx.net";
+ private static SimpleDateFormat ledgerDateFormatter =
+ new SimpleDateFormat("yyyy/MM/dd", Locale.US);
+ private static Pattern reLedgerDate =
+ Pattern.compile("^(?:(\\d+)/)??(?:(\\d\\d?)/)?(\\d\\d?)$");
+ public static void hideSoftKeyboard(Activity act) {
+ // hide the keyboard
+ View v = act.getCurrentFocus();
+ if (v != null) {
+ InputMethodManager imm =
+ (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
+ }
+ }
+ public static Date parseLedgerDate(String dateString) throws ParseException {
+ Matcher m = reLedgerDate.matcher(dateString);
+ if (!m.matches()) throw new ParseException(dateString, 0);
+
+ String year = m.group(1);
+ String month = m.group(2);
+ String day = m.group(3);
+
+ 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;