@Override
    public Date decodeFromString(String value) throws Exception {
        if (value.contains("y")) {
            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.MONTH, Calendar.JANUARY);
            cal.set(Calendar.DAY_OF_MONTH, 1);
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            cal.set(Calendar.MILLISECOND, 0);
            cal.set(Calendar.YEAR, Integer.valueOf(value.replace("y", "")));
            return cal.getTime();
        } else if (value.contains("d")) {
            Calendar cal = Calendar.getInstance();
            try {
                String[] years = value.replace("d", "").split("-");
                cal.set(Calendar.MONTH, Integer.valueOf(years[1]) - 1);
                cal.set(Calendar.DAY_OF_MONTH, Integer.valueOf(years[2]));
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
                cal.set(Calendar.YEAR, Integer.valueOf(years[0]));
            } catch (Throwable t) {
                log.warning("Cannot parse day scoped date '" + value + "'!");
            }
            return cal.getTime();
        } else if (value.contains("m")) {
            Calendar cal = Calendar.getInstance();
            try {
                String[] years = value.replace("m", "").split("-");
                cal.set(Calendar.MONTH, Integer.valueOf(years[1]) - 1);
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
                cal.set(Calendar.YEAR, Integer.valueOf(years[0]));
            } catch (Throwable t) {
                log.warning("Cannot parse day scoped date '" + value + "'!");
            }
            return cal.getTime();
        } else {
            return new Date(Long.valueOf(value));
        }
    }