Example usage for java.util Calendar APRIL

List of usage examples for java.util Calendar APRIL

Introduction

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

Prototype

int APRIL

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

Click Source Link

Document

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

Usage

From source file:org.hawkular.alerts.api.model.action.TimeConstraint.java

private int month(String sMonth) {
    if (isEmpty(sMonth)) {
        return -1;
    }//www . j av a 2s . c om
    if (sMonth.length() < 3) {
        return -1;
    }
    String prefix = sMonth.substring(0, 3).toLowerCase();
    MONTH m = MONTH.fromString(prefix);
    if (m == null) {
        return -1;
    }
    switch (m) {
    case JANUARY:
        return Calendar.JANUARY;
    case FEBRUARY:
        return Calendar.FEBRUARY;
    case MARCH:
        return Calendar.MARCH;
    case APRIL:
        return Calendar.APRIL;
    case MAY:
        return Calendar.MAY;
    case JUNE:
        return Calendar.JUNE;
    case JULY:
        return Calendar.JULY;
    case AUGUST:
        return Calendar.AUGUST;
    case SEPTEMBER:
        return Calendar.SEPTEMBER;
    case OCTOBER:
        return Calendar.OCTOBER;
    case NOVEMBER:
        return Calendar.NOVEMBER;
    case DECEMBER:
        return Calendar.DECEMBER;
    default:
        return -1;
    }
}

From source file:org.exoplatform.addons.es.rest.IndexingManagementRestServiceV1.java

private Response.ResponseBuilder getBadRequestResponse() {
    Calendar today = Calendar.getInstance();
    if (today.get(Calendar.DAY_OF_MONTH) == 1 && today.get(Calendar.MONTH) == Calendar.APRIL) {
        return Response.status(418);
    }/*from w ww.  j  ava2s . co m*/
    return Response.status(HTTPStatus.BAD_REQUEST);
}

From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java

public 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:
        // This is not correct. See isLeapYear(int) above
        //return (year % 4 == 0) ? 29 : 28;
        return isLeapYear(year) ? 29 : 28;
    default:/*w w  w  . ja  v  a  2  s .co  m*/
        throw new IllegalArgumentException("Invalid Month");
    }
}

From source file:com.stratelia.webactiv.util.DateUtilTest.java

@Test
public void testGetFirstDateOfWeekEN() {
    Date dateTest = DateUtil.getFirstDateOfWeek(java.sql.Date.valueOf("2013-04-20"), LANGUAGE);
    Calendar cal = DateUtil.convert(dateTest);
    assertThat(cal.get(Calendar.YEAR), is(2013));
    assertThat(cal.get(Calendar.MONTH), is(Calendar.APRIL));
    assertThat(cal.get(Calendar.DAY_OF_MONTH), is(14));
    assertThat(cal.get(Calendar.HOUR_OF_DAY), is(0));
    assertThat(cal.get(Calendar.MINUTE), is(0));
    assertThat(cal.get(Calendar.SECOND), is(0));
    assertThat(cal.get(Calendar.MILLISECOND), is(0));
}

From source file:com.stratelia.webactiv.util.DateUtilTest.java

@Test
public void testGetEndDateOfWeekEN() {
    Date dateTest = DateUtil.getEndDateOfWeek(java.sql.Date.valueOf("2013-04-20"), LANGUAGE);
    Calendar cal = DateUtil.convert(dateTest);
    assertThat(cal.get(Calendar.YEAR), is(2013));
    assertThat(cal.get(Calendar.MONTH), is(Calendar.APRIL));
    assertThat(cal.get(Calendar.DAY_OF_MONTH), is(20));
    assertThat(cal.get(Calendar.HOUR_OF_DAY), is(23));
    assertThat(cal.get(Calendar.MINUTE), is(59));
    assertThat(cal.get(Calendar.SECOND), is(59));
    assertThat(cal.get(Calendar.MILLISECOND), is(999));
}

From source file:br.msf.commons.util.AbstractDateUtils.java

protected static Collection<Calendar> getBrasilianHolidays(final int year) {
    Collection<Calendar> holidays = new ArrayList<>();

    // feriados fixos
    holidays.add(new GregorianCalendar(year, Calendar.JANUARY, 1)); // Confraternizacao Universal
    holidays.add(new GregorianCalendar(year, Calendar.APRIL, 21)); // Tiradentes
    holidays.add(new GregorianCalendar(year, Calendar.MAY, 1)); // Dia do Trabalho
    holidays.add(new GregorianCalendar(year, Calendar.OCTOBER, 12)); // Nossa Senhora Aparecida
    holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 2)); // Finados
    holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 15)); // Proclamacao da Republica
    holidays.add(new GregorianCalendar(year, Calendar.DECEMBER, 25)); // Natal

    // feriados calculados
    Calendar pascoa = getSundayOfEaster(year);
    Calendar carnaval = (Calendar) pascoa.clone();
    carnaval.add(Calendar.DAY_OF_MONTH, -47);
    Calendar corpusChristi = (Calendar) pascoa.clone();
    corpusChristi.add(Calendar.DAY_OF_MONTH, 60);

    holidays.add(carnaval); // Carnaval
    holidays.add(pascoa); // Pascoa
    holidays.add(corpusChristi); // Corpus Christi

    return holidays;
}

From source file:br.ojimarcius.commons.util.AbstractDateUtils.java

protected static Collection<Calendar> getBrasilianHolidays(final int year) {
    Collection<Calendar> holidays = new ArrayList<Calendar>();

    // feriados fixos
    holidays.add(new GregorianCalendar(year, Calendar.JANUARY, 1)); // Confraternizacao Universal
    holidays.add(new GregorianCalendar(year, Calendar.APRIL, 21)); // Tiradentes
    holidays.add(new GregorianCalendar(year, Calendar.MAY, 1)); // Dia do Trabalho
    holidays.add(new GregorianCalendar(year, Calendar.OCTOBER, 12)); // Nossa Senhora Aparecida
    holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 2)); // Finados
    holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 15)); // Proclamacao da Republica
    holidays.add(new GregorianCalendar(year, Calendar.DECEMBER, 25)); // Natal

    // feriados calculados
    Calendar pascoa = getSundayOfEaster(year);
    Calendar carnaval = (Calendar) pascoa.clone();
    carnaval.add(Calendar.DAY_OF_MONTH, -47);
    Calendar corpusChristi = (Calendar) pascoa.clone();
    corpusChristi.add(Calendar.DAY_OF_MONTH, 60);

    holidays.add(carnaval); // Carnaval
    holidays.add(pascoa); // Pascoa
    holidays.add(corpusChristi); // Corpus Christi

    return holidays;
}

From source file:com.stratelia.webactiv.util.DateUtilTest.java

@Test
public void testGetBeginOfDay() {
    Date dateTest = DateUtil.getBeginOfDay(java.sql.Date.valueOf("2013-04-20"));
    Calendar cal = DateUtil.convert(dateTest);
    assertThat(cal.get(Calendar.YEAR), is(2013));
    assertThat(cal.get(Calendar.MONTH), is(Calendar.APRIL));
    assertThat(cal.get(Calendar.DAY_OF_MONTH), is(20));
    assertThat(cal.get(Calendar.HOUR_OF_DAY), is(0));
    assertThat(cal.get(Calendar.MINUTE), is(0));
    assertThat(cal.get(Calendar.SECOND), is(0));
    assertThat(cal.get(Calendar.MILLISECOND), is(0));
}

From source file:com.stratelia.webactiv.util.DateUtilTest.java

@Test
public void testGetEndOfDay() {
    Date dateTest = DateUtil.getEndOfDay(java.sql.Date.valueOf("2013-04-20"));
    Calendar cal = DateUtil.convert(dateTest);
    assertThat(cal.get(Calendar.YEAR), is(2013));
    assertThat(cal.get(Calendar.MONTH), is(Calendar.APRIL));
    assertThat(cal.get(Calendar.DAY_OF_MONTH), is(20));
    assertThat(cal.get(Calendar.HOUR_OF_DAY), is(23));
    assertThat(cal.get(Calendar.MINUTE), is(59));
    assertThat(cal.get(Calendar.SECOND), is(59));
    assertThat(cal.get(Calendar.MILLISECOND), is(999));
}

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:/*from  w w  w . j a v a  2  s . com*/
        throw new IllegalArgumentException("Invalid Month");
    }
}