Example usage for java.util Calendar DECEMBER

List of usage examples for java.util Calendar DECEMBER

Introduction

In this page you can find the example usage for java.util Calendar DECEMBER.

Prototype

int DECEMBER

To view the source code for java.util Calendar DECEMBER.

Click Source Link

Document

Value of the #MONTH field indicating the twelfth month of the year in the Gregorian and Julian calendars.

Usage

From source file:agency.AgencyManagerImplTest.java

private static Mission newMission02() {
    Calendar missionBegin = new GregorianCalendar(2014, Calendar.DECEMBER, 6);
    Calendar missionEnd = new GregorianCalendar(2015, Calendar.FEBRUARY, 9);

    return newMission("Age of Ultron", missionBegin.getTime(), missionEnd.getTime(), 2, 2,
            "code name - Dark World");
}

From source file:nl.tricode.magnolia.blogs.templates.BlogRenderableDefinition.java

protected String getDateCreatedPredicate() {
    if (filter.containsKey(PARAM_YEAR)) {
        final int year = Integer.parseInt(filter.get(PARAM_YEAR));

        final Calendar start = Calendar.getInstance();
        start.set(year, Calendar.JANUARY, 1, 0, 0, 0);
        start.set(Calendar.MILLISECOND, 0);

        final Calendar end = Calendar.getInstance();
        end.set(year, Calendar.DECEMBER, 1, 23, 59, 59);
        end.set(Calendar.MILLISECOND, 999);

        if (filter.containsKey(PARAM_MONTH)) {
            final int month = Integer.parseInt(filter.get(PARAM_MONTH)) - 1;
            start.set(Calendar.MONTH, month);
            end.set(Calendar.MONTH, month);
        }//from  w w  w .j a  va  2  s.  c  om

        // Determine last day of the end month
        end.set(Calendar.DAY_OF_MONTH, end.getActualMaximum(Calendar.DAY_OF_MONTH));

        final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        // Format start date and end data for use in jcr sql predicate
        return "AND p.[mgnl:created] >= CAST('" + dateFormat.format(start.getTime()) + "' AS DATE) "
                + "AND p.[mgnl:created] <= CAST('" + dateFormat.format(end.getTime()) + "' AS DATE) ";
    }
    return StringUtils.EMPTY;
}

From source file:org.projectforge.common.DateHolder.java

public int daysBetween(final DateHolder other) {
    final DateHolder from, to;
    if (this.getTimeInMillis() < other.getTimeInMillis()) {
        from = this;
        to = other;//from w  ww. j ava2 s  .c om
    } else {
        from = other;
        to = this;
    }
    int result = 0;
    final int toYear = to.getYear();
    final DateHolder dh = new DateHolder(from.getDate());

    int endlessLoopProtection = 0;
    while (dh.getYear() < toYear) {
        final int fromDay = dh.getDayOfYear();
        dh.setMonth(Calendar.DECEMBER);
        dh.setDayOfMonth(31);
        result += dh.getDayOfYear() - fromDay + 1;
        dh.add(Calendar.DAY_OF_MONTH, 1);
        if (++endlessLoopProtection > 5000) {
            throw new IllegalArgumentException("Days between doesn's support more than 5000 years");
        }
    }
    result += to.getDayOfYear() - dh.getDayOfYear();
    if (this.getTimeInMillis() < other.getTimeInMillis()) {
        return result;
    } else {
        return -result;
    }
}

From source file:agency.AgentManagerImplTest.java

private static Agent newAgent02() {
    Calendar cal2 = new GregorianCalendar(1982, Calendar.DECEMBER, 5);

    return newAgent("Black widow", cal2.getTime(), 3, "One of the Avengers");
}

From source file:org.projectforge.framework.time.DateHolder.java

/**
 * @param other//  ww w.ja va2 s. c om
 * @return days between this and given date (other - this).
 */
public int daysBetween(final DateHolder other) {
    final DateHolder from, to;
    if (this.getTimeInMillis() < other.getTimeInMillis()) {
        from = this;
        to = other;
    } else {
        from = other;
        to = this;
    }
    int result = 0;
    final int toYear = to.getYear();
    final DateHolder dh = new DateHolder(from.getDate());

    int endlessLoopProtection = 0;
    while (dh.getYear() < toYear) {
        final int fromDay = dh.getDayOfYear();
        dh.setMonth(Calendar.DECEMBER);
        dh.setDayOfMonth(31);
        result += dh.getDayOfYear() - fromDay + 1;
        dh.add(Calendar.DAY_OF_MONTH, 1);
        if (++endlessLoopProtection > 5000) {
            throw new IllegalArgumentException("Days between doesn's support more than 5000 years");
        }
    }
    result += to.getDayOfYear() - dh.getDayOfYear();
    if (this.getTimeInMillis() < other.getTimeInMillis()) {
        return result;
    } else {
        return -result;
    }
}

From source file:com.tr4android.support.extension.picker.date.SimpleMonthView.java

private static int getDaysInMonth(int month, int year) {
    switch (month) {
    case Calendar.JANUARY:
    case Calendar.MARCH:
    case Calendar.MAY:
    case Calendar.JULY:
    case Calendar.AUGUST:
    case Calendar.OCTOBER:
    case Calendar.DECEMBER:
        return 31;
    case Calendar.APRIL:
    case Calendar.JUNE:
    case Calendar.SEPTEMBER:
    case Calendar.NOVEMBER:
        return 30;
    case Calendar.FEBRUARY:
        return (year % 4 == 0) ? 29 : 28;
    default:/*w  w w.ja v  a 2s  . c  o  m*/
        throw new IllegalArgumentException("Invalid Month");
    }
}

From source file:org.mifos.framework.util.helpers.DateUtils.java

public static Date getLastDayOfCurrentYear() {
    Calendar cal = getCurrentDateCalendar();
    cal.set(Calendar.MONTH, Calendar.DECEMBER);
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DATE));
    Calendar cal1 = getCurrentDateCalendar();
    cal1.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0);
    return new Date(cal1.getTimeInMillis());
}

From source file:org.mifos.framework.util.helpers.DateUtils.java

public static Date getLastDayOfNextYear() {
    Calendar cal = getCurrentDateCalendar();
    cal.set(Calendar.MONTH, Calendar.DECEMBER);
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DATE));
    Calendar cal1 = getCurrentDateCalendar();
    cal1.set(cal.get(Calendar.YEAR) + 1, cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0);
    return cal1.getTime();
}

From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java

@Test
public void testLang303() throws ParseException {
    DateParser parser = getInstance(YMD_SLASH);
    final Calendar cal = Calendar.getInstance();
    cal.set(2004, Calendar.DECEMBER, 31);

    final Date date = parser.parse("2004/11/31");

    parser = SerializationUtils.deserialize(SerializationUtils.serialize((Serializable) parser));
    assertEquals(date, parser.parse("2004/11/31"));
}

From source file:org.mifos.framework.util.helpers.DateUtils.java

public static Calendar getLastDayOfYearAfterNextYear() {
    Calendar cal = getCurrentDateCalendar();
    cal.set(Calendar.MONTH, Calendar.DECEMBER);
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DATE));
    Calendar cal1 = getCurrentDateCalendar();
    cal1.set(cal.get(Calendar.YEAR) + 2, cal.get(Calendar.MONTH), cal.get(Calendar.DATE), 0, 0, 0);
    return cal1;/*from w w  w .j  a  va  2  s  .  co m*/
}