Search in sources :

Example 1 with DateEnumForSearch

use of org.ovirt.engine.core.common.businessentities.DateEnumForSearch in project ovirt-engine by oVirt.

the class BaseConditionFieldAutoCompleter method dealWithDateEnum.

// private static final String DATE_FORMAT = "MMM dd,yyyy";
private static DateTime dealWithDateEnum(String value) {
    DateTime formatedValue = new DateTime();
    final Integer result = IntegerCompat.tryParse(StringHelper.trim(value, '\''));
    if (result != null) {
        DateEnumForSearch dateEnumVal = DateEnumForSearch.forValue(result);
        switch(dateEnumVal) {
            case Today:
                formatedValue = DateTime.getNow();
                break;
            case Yesterday:
                formatedValue = DateTime.getNow().addDays(-1);
                break;
            default:
                break;
        }
    } else {
        for (int i = -2; i > -8; i--) {
            if (DateUtils.getDayOfWeek(i).equalsIgnoreCase(StringHelper.trim(value, '\''))) {
                formatedValue = DateTime.getNow().addDays(i);
                return formatedValue.resetToMidnight();
            }
        }
    }
    return formatedValue.resetToMidnight();
}
Also used : DateEnumForSearch(org.ovirt.engine.core.common.businessentities.DateEnumForSearch) DateTime(org.ovirt.engine.core.compat.DateTime)

Aggregations

DateEnumForSearch (org.ovirt.engine.core.common.businessentities.DateEnumForSearch)1 DateTime (org.ovirt.engine.core.compat.DateTime)1