Example usage for java.util Calendar MARCH

List of usage examples for java.util Calendar MARCH

Introduction

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

Prototype

int MARCH

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

Click Source Link

Document

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

Usage

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for getting calendar number of month by month
 * description//from  w w  w .ja v  a 2  s.  c  om
 * 
 * @param monthDescr
 * @return
 */
public static int getMonthNum(String monthDescr) {
    int numOfMonth = -1;
    if (DateTimeConstants.JANUARY.equals(monthDescr)) {
        numOfMonth = Calendar.JANUARY;
    }
    if (DateTimeConstants.FEBRUARY.equals(monthDescr)) {
        numOfMonth = Calendar.FEBRUARY;
    }
    if (DateTimeConstants.MARCH.equals(monthDescr)) {
        numOfMonth = Calendar.MARCH;
    }
    if (DateTimeConstants.APRIL.equals(monthDescr)) {
        numOfMonth = Calendar.APRIL;
    }
    if (DateTimeConstants.MAY.equals(monthDescr)) {
        numOfMonth = Calendar.MAY;
    }
    if (DateTimeConstants.JUNE.equals(monthDescr)) {
        numOfMonth = Calendar.JUNE;
    }
    if (DateTimeConstants.JULY.equals(monthDescr)) {
        numOfMonth = Calendar.JULY;
    }
    if (DateTimeConstants.AUGUST.equals(monthDescr)) {
        numOfMonth = Calendar.AUGUST;
    }
    if (DateTimeConstants.SEPTEMBER.equals(monthDescr)) {
        numOfMonth = Calendar.SEPTEMBER;
    }
    if (DateTimeConstants.OCTOBER.equals(monthDescr)) {
        numOfMonth = Calendar.OCTOBER;
    }
    if (DateTimeConstants.NOVEMBER.equals(monthDescr)) {
        numOfMonth = Calendar.NOVEMBER;
    }
    if (DateTimeConstants.DECEMBER.equals(monthDescr)) {
        numOfMonth = Calendar.DECEMBER;
    }
    return numOfMonth;
}

From source file:edu.northwestern.bioinformatics.studycalendar.web.schedule.ScheduleActivityCommandTest.java

public void testChangeTimeWitAmPmFormat() throws Exception {
    assertEquals("Unexpected number of initial states", 1, event.getAllStates().size());
    assertNull(event.getNotes());/*  ww w. j a  v a2  s.c  om*/

    command.setNewMode(ScheduledActivityMode.SCHEDULED);
    command.setNewTime("5:15 AM");
    scheduledCalendarDao.save(event.getScheduledStudySegment().getScheduledCalendar());

    replayMocks();
    command.apply();
    verifyMocks();

    assertEquals("Wrong number of states", 2, event.getAllStates().size());
    assertEquals("Wrong mode for current state", ScheduledActivityMode.SCHEDULED,
            event.getCurrentState().getMode());
    assertEquals("Wrong withTime for current state", (Object) true, event.getCurrentState().getWithTime());
    assertEquals("Wrong Date for current state", DateUtils.createDate(2003, Calendar.MARCH, 14, 5, 15, 00),
            event.getCurrentState().getDate());
}

From source file:com.swiftcorp.portal.common.util.CalendarUtils.java

@Deprecated
public static Calendar addMonthDayToCal(Calendar cal, int month, int day) {
    Date d = new Date();
    int daysToAdd = 0;
    // Calendar cal = Calendar.getInstance();
    int currentMonth = cal.get(2);
    long t = 0;//from  w  w  w . j  a  v  a2  s. c  o m

    t = d.getTime();
    if (month > 0) {
        // cal.get ( month );
        for (int i = 0; i < month; i++) {
            if (currentMonth < 12) {
                if (currentMonth == Calendar.JANUARY) {
                    cal.set(2, Calendar.JANUARY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.FEBRUARY) {
                    cal.set(2, Calendar.FEBRUARY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.MARCH) {
                    cal.set(2, Calendar.MARCH);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.APRIL) {
                    cal.set(2, Calendar.APRIL);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.MAY) {
                    cal.set(2, Calendar.MAY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.JUNE) {
                    cal.set(2, Calendar.JUNE);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.JULY) {
                    cal.set(2, Calendar.JULY);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.AUGUST) {
                    cal.set(2, Calendar.AUGUST);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.SEPTEMBER) {
                    cal.set(2, Calendar.SEPTEMBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.OCTOBER) {
                    cal.set(2, Calendar.OCTOBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.NOVEMBER) {
                    cal.set(2, Calendar.NOVEMBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                } else if (currentMonth == Calendar.DECEMBER) {
                    cal.set(2, Calendar.DECEMBER);
                    daysToAdd += cal.getActualMaximum(Calendar.DAY_OF_MONTH);
                }
                currentMonth++;
            } else {
                currentMonth = 0;
                i--;
            }
        }
    }
    daysToAdd += day;
    // add the desired number of days to the long value using milli seconds

    t += daysToAdd * MILLIS_PER_DAY;
    cal.setTime(new Date(t));
    // and now you can format the date the way you want
    String result = Integer.toString(cal.get(Calendar.DAY_OF_MONTH)) + "-"
            + Integer.toString(cal.get(Calendar.MONTH) + 1) + "-" + Integer.toString(cal.get(Calendar.YEAR));
    System.out.println("result month add::" + result);
    return cal;
}

From source file:com.clustercontrol.systemlog.bean.SyslogMessage.java

/**
 * ??//from  ww  w .  ja va 2 s  .c  o m
 * ?(String)Calendar?(int)???
 * 
 * @param month 
 * @return Calendar?
 */
private static int editCalendarMonth(String month) {

    switch (month.toUpperCase()) {
    case "JAN":
        return Calendar.JANUARY;
    case "FEB":
        return Calendar.FEBRUARY;
    case "MAR":
        return Calendar.MARCH;
    case "APR":
        return Calendar.APRIL;
    case "MAY":
        return Calendar.MAY;
    case "JUN":
        return Calendar.JUNE;
    case "JUL":
        return Calendar.JULY;
    case "AUG":
        return Calendar.AUGUST;
    case "SEP":
        return Calendar.SEPTEMBER;
    case "OCT":
        return Calendar.OCTOBER;
    case "NOV":
        return Calendar.NOVEMBER;
    case "DEC":
        return Calendar.DECEMBER;
    }
    return Calendar.UNDECIMBER;
}

From source file:org.kuali.kfs.module.endow.businessobject.lookup.CalculateProcessDateUsingFrequencyCodeService.java

/**
 * This method will check the current month and set the calendar to that month
 * @param month month to set the calendar
 * @return calendar calendar is set to the month selected
 *//*from   w w  w.j av a 2  s  .  c om*/
protected Calendar setCaledarWithMonth(String month, Date currentDate) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(currentDate);
    int calendarMonth = 1;

    if (EndowConstants.FrequencyMonths.JANUARY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JANUARY;
    } else if (EndowConstants.FrequencyMonths.FEBRUARY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.FEBRUARY;
    } else if (EndowConstants.FrequencyMonths.MARCH.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.MARCH;
    } else if (EndowConstants.FrequencyMonths.APRIL.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.APRIL;
    } else if (EndowConstants.FrequencyMonths.MAY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.MAY;
    } else if (EndowConstants.FrequencyMonths.JUNE.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JUNE;
    } else if (EndowConstants.FrequencyMonths.JULY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JULY;
    } else if (EndowConstants.FrequencyMonths.AUGUST.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.AUGUST;
    } else if (EndowConstants.FrequencyMonths.SEPTEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.SEPTEMBER;
    } else if (EndowConstants.FrequencyMonths.OCTOBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.OCTOBER;
    } else if (EndowConstants.FrequencyMonths.NOVEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.NOVEMBER;
    } else if (EndowConstants.FrequencyMonths.DECEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.DECEMBER;
    }

    calendar.set(Calendar.MONTH, calendarMonth);

    return calendar;
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.sop.examsMapNew.renderers.ExamsMapContentRenderer.java

private String monthToString(int month, Locale locale) {
    switch (month) {

    case Calendar.JANUARY:
        if (locale.getLanguage().equals("pt")) {
            return "Janeiro";
        }/*from ww  w.j  a v a2 s .c  om*/
        return "January";
    case Calendar.FEBRUARY:
        if (locale.getLanguage().equals("pt")) {
            return "Fevereiro";
        }
        return "February";
    case Calendar.MARCH:
        if (locale.getLanguage().equals("pt")) {
            return "Maro";
        }
        return "March";
    case Calendar.APRIL:
        if (locale.getLanguage().equals("pt")) {
            return "Abril";
        }
        return "April";
    case Calendar.MAY:
        if (locale.getLanguage().equals("pt")) {
            return "Maio";
        }
        return "May";
    case Calendar.JUNE:
        if (locale.getLanguage().equals("pt")) {
            return "Junho";
        }
        return "June";
    case Calendar.JULY:
        if (locale.getLanguage().equals("pt")) {
            return "Julho";
        }
        return "July";
    case Calendar.AUGUST:
        if (locale.getLanguage().equals("pt")) {
            return "Agosto";
        }
        return "August";
    case Calendar.SEPTEMBER:
        if (locale.getLanguage().equals("pt")) {
            return "Setembro";
        }
        return "September";
    case Calendar.OCTOBER:
        if (locale.getLanguage().equals("pt")) {
            return "Outubro";
        }
        return "October";
    case Calendar.NOVEMBER:
        if (locale.getLanguage().equals("pt")) {
            return "Novembro";
        }
        return "November";
    case Calendar.DECEMBER:
        if (locale.getLanguage().equals("pt")) {
            return "Dezembro";
        }
        return "December";
    case Calendar.UNDECIMBER:
        return "Undecember";
    default:
        return "Error";
    }
}

From source file:org.kuali.kfs.module.endow.document.service.impl.FrequencyDatesServiceImpl.java

/**
 * This method will check the current month and set the calendar to that month
 * @param month month to set the calendar
 * @return calendar calendar is set to the month selected
 *//*  w  w  w. j a  va  2s . c  o  m*/
protected Calendar setCalendarWithMonth(String month, Date currentDate) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(currentDate);
    int calendarMonth = Calendar.JANUARY;

    if (EndowConstants.FrequencyMonths.JANUARY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JANUARY;
    } else if (EndowConstants.FrequencyMonths.FEBRUARY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.FEBRUARY;
    } else if (EndowConstants.FrequencyMonths.MARCH.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.MARCH;
    } else if (EndowConstants.FrequencyMonths.APRIL.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.APRIL;
    } else if (EndowConstants.FrequencyMonths.MAY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.MAY;
    } else if (EndowConstants.FrequencyMonths.JUNE.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JUNE;
    } else if (EndowConstants.FrequencyMonths.JULY.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.JULY;
    } else if (EndowConstants.FrequencyMonths.AUGUST.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.AUGUST;
    } else if (EndowConstants.FrequencyMonths.SEPTEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.SEPTEMBER;
    } else if (EndowConstants.FrequencyMonths.OCTOBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.OCTOBER;
    } else if (EndowConstants.FrequencyMonths.NOVEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.NOVEMBER;
    } else if (EndowConstants.FrequencyMonths.DECEMBER.equalsIgnoreCase(month)) {
        calendarMonth = Calendar.DECEMBER;
    }

    calendar.set(Calendar.MONTH, calendarMonth);

    return calendar;
}

From source file:org.openmrs.module.radiology.web.controller.PortletsControllerTest.java

/**
 * @see PortletsController#filterRadiologyOrdersByDateRange(List<RadiologyOrder>, Date, Date)
 * @verifies return empty list of orders with given end date and start date before any order has started
 *//*from  w ww  .jav a2s  . c o  m*/
@Test
public void filterRadiologyOrdersByDateRange_shouldReturnListOfOrdersAssociatedWithGivenEndDateAndStartDateBeforeAnyOrderHasStarted()
        throws Exception {

    //given
    Date startDate = new GregorianCalendar(2014, Calendar.MARCH, 01).getTime();
    Date endDate = new GregorianCalendar(2014, Calendar.MAY, 01).getTime();

    Method filterRadiologyOrdersByDateRangeMethod = portletsController.getClass().getDeclaredMethod(
            "filterRadiologyOrdersByDateRange",
            new Class[] { java.util.List.class, java.util.Date.class, java.util.Date.class });
    filterRadiologyOrdersByDateRangeMethod.setAccessible(true);

    List<RadiologyOrder> filteredRadiologyOrdersByDateRange = (List<RadiologyOrder>) filterRadiologyOrdersByDateRangeMethod
            .invoke(portletsController, new Object[] { mockRadiologyOrders, startDate, endDate });

    assertThat(filteredRadiologyOrdersByDateRange, is(notNullValue()));
    assertThat(filteredRadiologyOrdersByDateRange, is(empty()));
}

From source file:com.gemstone.gemfire.rest.internal.web.controllers.RestAPIsAndInterOpsDUnitTest.java

public static void doPutsInClientCache() {
    ClientCache cache = GemFireCacheImpl.getInstance();
    assertNotNull(cache);/*from  ww  w. j av  a 2 s  .  c o m*/
    Region<String, Object> region = cache.getRegion(PEOPLE_REGION_NAME);

    //put person object
    final Person person1 = new Person(101L, "Mithali", "Dorai", "Raj",
            DateTimeUtils.createDate(1982, Calendar.DECEMBER, 4), Gender.FEMALE);
    final Person person2 = new Person(102L, "Sachin", "Ramesh", "Tendulkar",
            DateTimeUtils.createDate(1975, Calendar.DECEMBER, 14), Gender.MALE);
    final Person person3 = new Person(103L, "Saurabh", "Baburav", "Ganguly",
            DateTimeUtils.createDate(1972, Calendar.AUGUST, 29), Gender.MALE);
    final Person person4 = new Person(104L, "Rahul", "subrymanyam", "Dravid",
            DateTimeUtils.createDate(1979, Calendar.MARCH, 17), Gender.MALE);
    final Person person5 = new Person(105L, "Jhulan", "Chidambaram", "Goswami",
            DateTimeUtils.createDate(1983, Calendar.NOVEMBER, 25), Gender.FEMALE);

    region.put("1", person1);
    region.put("2", person2);
    region.put("3", person3);
    region.put("4", person4);
    region.put("5", person5);

    final Person person6 = new Person(101L, "Rahul", "Rajiv", "Gndhi",
            DateTimeUtils.createDate(1970, Calendar.MAY, 14), Gender.MALE);
    final Person person7 = new Person(102L, "Narendra", "Damodar", "Modi",
            DateTimeUtils.createDate(1945, Calendar.DECEMBER, 24), Gender.MALE);
    final Person person8 = new Person(103L, "Atal", "Bihari", "Vajpayee",
            DateTimeUtils.createDate(1920, Calendar.AUGUST, 9), Gender.MALE);
    final Person person9 = new Person(104L, "Soniya", "Rajiv", "Gandhi",
            DateTimeUtils.createDate(1929, Calendar.MARCH, 27), Gender.FEMALE);
    final Person person10 = new Person(104L, "Priyanka", "Robert", "Gandhi",
            DateTimeUtils.createDate(1973, Calendar.APRIL, 15), Gender.FEMALE);

    final Person person11 = new Person(104L, "Murali", "Manohar", "Joshi",
            DateTimeUtils.createDate(1923, Calendar.APRIL, 25), Gender.MALE);
    final Person person12 = new Person(104L, "Lalkrishna", "Parmhansh", "Advani",
            DateTimeUtils.createDate(1910, Calendar.JANUARY, 01), Gender.MALE);
    final Person person13 = new Person(104L, "Shushma", "kumari", "Swaraj",
            DateTimeUtils.createDate(1943, Calendar.AUGUST, 10), Gender.FEMALE);
    final Person person14 = new Person(104L, "Arun", "raman", "jetly",
            DateTimeUtils.createDate(1942, Calendar.OCTOBER, 27), Gender.MALE);
    final Person person15 = new Person(104L, "Amit", "kumar", "shah",
            DateTimeUtils.createDate(1958, Calendar.DECEMBER, 21), Gender.MALE);
    final Person person16 = new Person(104L, "Shila", "kumari", "Dixit",
            DateTimeUtils.createDate(1927, Calendar.FEBRUARY, 15), Gender.FEMALE);

    Map<String, Object> userMap = new HashMap<String, Object>();
    userMap.put("6", person6);
    userMap.put("7", person7);
    userMap.put("8", person8);
    userMap.put("9", person9);
    userMap.put("10", person10);
    userMap.put("11", person11);
    userMap.put("12", person12);
    userMap.put("13", person13);
    userMap.put("14", person14);
    userMap.put("15", person15);
    userMap.put("16", person16);

    region.putAll(userMap);

    if (cache != null)
        cache.getLogger().info("Gemfire Cache Client: Puts successfully done");

}

From source file:org.apache.metron.dataloads.bulk.ElasticsearchDataPrunerTest.java

@Before
public void setUp() throws Exception {

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.MONTH, Calendar.MARCH);
    calendar.set(Calendar.YEAR, 2016);
    calendar.set(Calendar.DATE, 31);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    testDate = calendar.getTime();/*from   www .  j a  v a2s  . c  o m*/

    when(indexClient.admin()).thenReturn(adminClient);
    when(adminClient.indices()).thenReturn(indicesAdminClient);
    when(deleteIndexRequestBuilder.request()).thenReturn(deleteIndexRequest);
    when(deleteIndexAction.actionGet()).thenReturn(deleteIndexResponse);

    File resourceFile = new File(TestConstants.SAMPLE_CONFIG_PATH);
    Path resourcePath = Paths.get(resourceFile.getCanonicalPath());

    configuration = new Configuration(resourcePath);

    outContent = new ByteArrayOutputStream();
    errContent = new ByteArrayOutputStream();

    System.setOut(new PrintStream(outContent));
    System.setErr(new PrintStream(errContent));

}