Example usage for com.liferay.portal.kernel.util DateUtil getISOFormat

List of usage examples for com.liferay.portal.kernel.util DateUtil getISOFormat

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util DateUtil getISOFormat.

Prototype

public static DateFormat getISOFormat() 

Source Link

Usage

From source file:com.liferay.jbpm.db.GraphSession.java

License:Open Source License

private Timestamp _getDate(String date, boolean greaterThan) {
    if (Validator.isNull(date)) {
        return null;
    } else {//w w w .  j ava2 s.c  o  m
        Calendar calendar = Calendar.getInstance();

        DateFormat dateFormat = DateUtil.getISOFormat();

        calendar.setTime(GetterUtil.getDate(date, dateFormat));

        if (greaterThan) {
            calendar.set(Calendar.HOUR_OF_DAY, 0);
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);
        } else {
            calendar.set(Calendar.HOUR_OF_DAY, 23);
            calendar.set(Calendar.MINUTE, 59);
            calendar.set(Calendar.SECOND, 59);
            calendar.set(Calendar.MILLISECOND, 999);
        }

        TimeZone timeZone = TimeZone.getTimeZone(_timeZoneId);

        int offset = timeZone.getOffset(calendar.getTimeInMillis());

        return new Timestamp(calendar.getTimeInMillis() - offset);
    }
}