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:ISO8601DateTimeFormat.java

/**
 * Write century, year, and months.//w  w  w. ja  va2  s .  com
 * @param sbuf The buffer to append the string.
 */
protected final void writeCCYYMM(StringBuffer sbuf) {
    int year = calendar.get(Calendar.YEAR);
    appendInt(sbuf, year, 4);

    String month;
    switch (calendar.get(Calendar.MONTH)) {
    case Calendar.JANUARY:
        month = "-01-";
        break;
    case Calendar.FEBRUARY:
        month = "-02-";
        break;
    case Calendar.MARCH:
        month = "-03-";
        break;
    case Calendar.APRIL:
        month = "-04-";
        break;
    case Calendar.MAY:
        month = "-05-";
        break;
    case Calendar.JUNE:
        month = "-06-";
        break;
    case Calendar.JULY:
        month = "-07-";
        break;
    case Calendar.AUGUST:
        month = "-08-";
        break;
    case Calendar.SEPTEMBER:
        month = "-09-";
        break;
    case Calendar.OCTOBER:
        month = "-10-";
        break;
    case Calendar.NOVEMBER:
        month = "-11-";
        break;
    case Calendar.DECEMBER:
        month = "-12-";
        break;
    default:
        month = "-NA-";
        break;
    }
    sbuf.append(month);

    int day = calendar.get(Calendar.DAY_OF_MONTH);
    appendInt(sbuf, day, 2);
}

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

public void doPutsInClientCache() {
    ClientCache cache = GemFireCacheImpl.getInstance();
    assertNotNull(cache);/*from  w w  w. j a v  a  2s. 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:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for getting month long description
 * //  w ww  . j a v  a2 s . c  o m
 * @param mthNum
 * @return
 */
public static String getMonthLongDesc(int mthNum) {
    String mthLongDesc;

    switch (mthNum) {
    case Calendar.JANUARY: {
        mthLongDesc = DateTimeConstants.JANUARY;
        break;
    }
    case Calendar.FEBRUARY: {
        mthLongDesc = DateTimeConstants.FEBRUARY;
        break;
    }
    case Calendar.MARCH: {
        mthLongDesc = DateTimeConstants.MARCH;
        break;
    }
    case Calendar.APRIL: {
        mthLongDesc = DateTimeConstants.APRIL;
        break;
    }
    case Calendar.MAY: {
        mthLongDesc = DateTimeConstants.MAY;
        break;
    }
    case Calendar.JUNE: {
        mthLongDesc = DateTimeConstants.JUNE;
        break;
    }
    case Calendar.JULY: {
        mthLongDesc = DateTimeConstants.JULY;
        break;
    }
    case Calendar.AUGUST: {
        mthLongDesc = DateTimeConstants.AUGUST;
        break;
    }
    case Calendar.SEPTEMBER: {
        mthLongDesc = DateTimeConstants.SEPTEMBER;
        break;
    }
    case Calendar.OCTOBER: {
        mthLongDesc = DateTimeConstants.OCTOBER;
        break;
    }
    case Calendar.NOVEMBER: {
        mthLongDesc = DateTimeConstants.NOVEMBER;
        break;
    }
    case Calendar.DECEMBER: {
        mthLongDesc = DateTimeConstants.DECEMBER;
        break;
    }
    default: {
        mthLongDesc = "";
        break;
    }
    }

    return mthLongDesc;
}

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

/**
 * @see PortletsController#getRadiologyOrdersByPatientQueryAndDateRange(String, Date, Date)
 * @verifies populate model and view with table of orders including obsId accessed as reading physician
 *//*from   w  w  w.j a  v  a 2s.  co m*/
@Test
public void getRadiologyOrdersByPatientQueryAndDateRange_shouldPopulateModelAndViewWithTableOfOrdersIncludingObsIdAccessedAsReadingPhysician()
        throws Exception {

    //given
    String patientQuery = "";
    Date startDate = null;
    Date endDate = new GregorianCalendar(2015, Calendar.MARCH, 01).getTime();

    when(Context.getAuthenticatedUser()).thenReturn(RadiologyTestData.getMockRadiologyReadingPhysician());

    ModelAndView mav = portletsController.getRadiologyOrdersByPatientQueryAndDateRange(patientQuery, startDate,
            endDate);
    assertThat(mav, is(notNullValue()));

    assertThat(mav.getModelMap(), hasKey("orderList"));
    List<RadiologyOrder> orderList = (List<RadiologyOrder>) mav.getModelMap().get("orderList");
    assertThat(orderList, is(notNullValue()));
    assertThat(orderList, is(Arrays.asList(mockRadiologyOrder1)));

    assertThat(mav.getModelMap(), hasKey("obsId"));
    String obsId = (String) mav.getModelMap().get("obsId");
    assertThat(obsId, is(notNullValue()));
    assertThat(obsId, is("&obsId"));
}

From source file:org.opennms.netmgt.syslogd.SyslogMessageTest.java

@Test
public void testCustomParserNms5242() throws Exception {
    final Locale startLocale = Locale.getDefault();
    try {//from  ww w  .  ja  va  2s .c o m
        Locale.setDefault(Locale.FRANCE);
        final InputStream stream = new ByteArrayInputStream(("<?xml version=\"1.0\"?>\n"
                + "<syslogd-configuration>\n" + "    <configuration\n" + "            syslog-port=\"10514\"\n"
                + "            new-suspect-on-message=\"false\"\n"
                + "            parser=\"org.opennms.netmgt.syslogd.CustomSyslogParser\"\n"
                + "            forwarding-regexp=\"^((.+?) (.*))\\n?$\"\n"
                + "            matching-group-host=\"2\"\n" + "            matching-group-message=\"3\"\n"
                + "            discard-uei=\"DISCARD-MATCHING-MESSAGES\"\n" + "            />\n" + "\n"
                + "    <hideMessage>\n" + "        <hideMatch>\n"
                + "            <match type=\"substr\" expression=\"TEST\"/>\n" + "        </hideMatch>\n"
                + "    </hideMessage>\n" + "</syslogd-configuration>\n").getBytes());
        final SyslogdConfigFactory config = new SyslogdConfigFactory(stream);

        final SyslogParser parser = new CustomSyslogParser(config,
                "<0>Mar 14 17:10:25 petrus sudo:  cyrille : user NOT in sudoers ; TTY=pts/2 ; PWD=/home/cyrille ; USER=root ; COMMAND=/usr/bin/vi /etc/aliases");
        assertTrue(parser.find());
        final SyslogMessage message = parser.parse();
        LOG.debug("message = {}", message);
        final Calendar cal = Calendar.getInstance();
        cal.setTimeZone(TimeZone.getTimeZone("UTC"));
        cal.set(Calendar.MONTH, Calendar.MARCH);
        cal.set(Calendar.DAY_OF_MONTH, 14);
        cal.set(Calendar.HOUR_OF_DAY, 17);
        cal.set(Calendar.MINUTE, 10);
        cal.set(Calendar.SECOND, 25);
        cal.set(Calendar.MILLISECOND, 0);
        assertEquals(SyslogFacility.KERNEL, message.getFacility());
        assertEquals(SyslogSeverity.EMERGENCY, message.getSeverity());
        assertNull(message.getMessageID());
        assertEquals(cal.getTime(), message.getDate());
        assertEquals("petrus", message.getHostName());
        assertEquals("sudo", message.getProcessName());
        assertEquals(0, message.getProcessId().intValue());
        assertEquals(
                "cyrille : user NOT in sudoers ; TTY=pts/2 ; PWD=/home/cyrille ; USER=root ; COMMAND=/usr/bin/vi /etc/aliases",
                message.getMessage());
    } finally {
        Locale.setDefault(startLocale);
    }
}

From source file:edu.mayo.informatics.lexgrid.convert.directConversions.UMLSHistoryFileToSQL.java

private Date getSystemReleaseDate(String releaseId) throws Exception {
    String sYear = releaseId.substring(0, 4);
    int year = new Integer(sYear).intValue();

    String sMonth = releaseId.substring(4);
    int mon = 0;//w  ww .j a va  2s . com

    Calendar cal = Calendar.getInstance();
    if ("AA".equalsIgnoreCase(sMonth)) {
        mon = Calendar.JANUARY;
    } else if ("AB".equalsIgnoreCase(sMonth)) {
        mon = Calendar.APRIL;
    } else if ("AC".equalsIgnoreCase(sMonth)) {
        mon = Calendar.JULY;
    } else if ("AD".equalsIgnoreCase(sMonth)) {
        mon = Calendar.OCTOBER;
    } else {
        try {
            int i = Integer.parseInt(sMonth);

            switch (i) {
            case 1:
                mon = Calendar.JANUARY;
                break;
            case 2:
                mon = Calendar.FEBRUARY;
                break;
            case 3:
                mon = Calendar.MARCH;
                break;
            case 4:
                mon = Calendar.APRIL;
                break;
            case 5:
                mon = Calendar.MAY;
                break;
            case 6:
                mon = Calendar.JUNE;
                break;
            case 7:
                mon = Calendar.JULY;
                break;
            case 8:
                mon = Calendar.AUGUST;
                break;
            case 9:
                mon = Calendar.SEPTEMBER;
                break;
            case 10:
                mon = Calendar.OCTOBER;
                break;
            case 11:
                mon = Calendar.NOVEMBER;
                break;
            case 12:
                mon = Calendar.DECEMBER;
                break;

            default:
                throw new Exception("Release ID is not in required format: " + sMonth);
            }
        } catch (NumberFormatException e) {
            throw new Exception("Release ID is not in required format." + sMonth);
        }

    }
    cal.set(year, mon, 01, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);

    return new Date(cal.getTimeInMillis());
}

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

public void testChangeTimeWith24HrFormat() throws Exception {
    assertEquals("Unexpected number of initial states", 1, event.getAllStates().size());
    assertNull(event.getNotes());/*from w w w . ja va2 s  . co  m*/

    command.setNewMode(ScheduledActivityMode.SCHEDULED);
    command.setNewTime("19:25");
    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, 19, 25, 00),
            event.getCurrentState().getDate());
}

From source file:com.stratelia.silverpeas.versioning.jcr.impl.AbstractJcrTestCase.java

@Before
public void onSetUp() throws Exception {
    System.getProperties().put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
    calend = Calendar.getInstance();
    calend.set(Calendar.MILLISECOND, 0);
    calend.set(Calendar.SECOND, 0);
    calend.set(Calendar.MINUTE, 15);
    calend.set(Calendar.HOUR, 9);
    calend.set(Calendar.DAY_OF_MONTH, 12);
    calend.set(Calendar.MONTH, Calendar.MARCH);
    calend.set(Calendar.YEAR, 2008);
    IDatabaseConnection connection = null;
    try {/*from  w w  w  . j  ava2  s .  c  o  m*/
        connection = new DatabaseConnection(datasource.getConnection());
        DatabaseOperation.CLEAN_INSERT.execute(connection, getDataSet());
    } catch (Exception ex) {
        throw ex;
    } finally {
        if (connection != null) {
            try {
                connection.getConnection().close();
            } catch (SQLException e) {
                throw e;
            }
        }
    }
}

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

/**
 * @see PortletsController#filterRadiologyOrdersByDateRange(List<RadiologyOrder>, Date, Date)
 * @verifies return list of orders matching a given date range
 *///from  www.  j  a v  a2s .c o  m
@Test
public void filterRadiologyOrdersByDateRange_shouldPopulateModelAndViewWithTableOfOrdersAssociatedWithGivenDateRange()
        throws Exception {

    //given
    Date startDate = new GregorianCalendar(2000, Calendar.MARCH, 01).getTime();
    Date endDate = new GregorianCalendar(2020, 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(mockRadiologyOrders));
}

From source file:edu.virginia.iath.oxygenplugins.dateparser.helpers.SNACDate.java

private Calendar[] getSeasonDates(String seasonStr, int year) {
    Calendar[] seasonDates = new Calendar[2];
    String season = seasonStr.toLowerCase().trim();

    seasonDates[0] = Calendar.getInstance();
    seasonDates[1] = Calendar.getInstance();

    // Note: Java is WEIRD:  0 = JANUARY, 1 = FEBRUARY, ...
    if (season.equals("winter")) {
        seasonDates[0].set(year - 1, Calendar.DECEMBER, 21);
        seasonDates[1].set(year, Calendar.MARCH, 19);

    } else if (season.equals("spring")) {
        seasonDates[0].set(year, Calendar.MARCH, 20);
        seasonDates[1].set(year, Calendar.JUNE, 20);

    } else if (season.equals("fall") || season.equals("autumn")) {
        seasonDates[0].set(year, Calendar.SEPTEMBER, 22);
        seasonDates[1].set(year, Calendar.DECEMBER, 20);

    } else if (season.equals("summer")) {
        seasonDates[0].set(year, Calendar.JUNE, 21);
        seasonDates[1].set(year, Calendar.SEPTEMBER, 21);

    }//from   ww w.  j  a  v a 2s. c  o m

    return seasonDates;
}