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: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 after any order has started
 *//*w  ww  .j  a  va2s.com*/
@Test
public void filterRadiologyOrdersByDateRange_shouldReturnListOfOrdersAssociatedWithGivenEndDateAndStartDateAfterAnyOrderHasStarted()
        throws Exception {

    //given
    Date startDate = new GregorianCalendar(2016, Calendar.MARCH, 01).getTime();
    Date endDate = new GregorianCalendar(2016, 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:org.jfree.data.time.MonthTest.java

/**
 * Some checks for the getStart() method.
 *///ww  w.  j  av a  2 s.com
@Test
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.MARCH, 1, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Month m = new Month(3, 2006);
    assertEquals(cal.getTime(), m.getStart());
    Locale.setDefault(saved);
}

From source file:edu.virginia.iath.snac.helpers.datastructures.SNACDate.java

/**
 * Gets the season dates for the given season and year.  Since the season dates only change
 * +/- 2 days across most of time, we store a lookup table and calculate them directly.
 * Winter starts in December of the previous year and ends in the given year.
 * /*from   w  w w  .j a  v  a2  s  . c  o  m*/
 * @param seasonStr Season to lookup (summer, spring, fall, autumn, winter)
 * @param year 4-digit year.
 * @return Array of Java Calendar objects containing the beginning and end dates of the season.
 */
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);

    }

    return seasonDates;
}

From source file:org.jfree.data.time.QuarterTest.java

/**
 * Some checks for the getEnd() method./* ww  w.  j a  v  a  2 s  .  c o  m*/
 */
@Test
public void testGetEnd() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.MARCH, 31, 23, 59, 59);
    cal.set(Calendar.MILLISECOND, 999);
    Quarter q = new Quarter(1, 2006);
    assertEquals(cal.getTime(), q.getEnd());
    Locale.setDefault(saved);
}

From source file:org.jfree.data.time.junit.MonthTest.java

/**
 * Some checks for the getStart() method.
 */// w w w .j  a v a  2s .c o m
public void testGetStart() {
    Locale saved = Locale.getDefault();
    Locale.setDefault(Locale.ITALY);
    Calendar cal = Calendar.getInstance(Locale.ITALY);
    cal.set(2006, Calendar.MARCH, 1, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    Month m = new Month(3, 2006);
    assertEquals(cal.getTime(), m.getStart());
    Locale.setDefault(saved);
}

From source file:Time.java

/**
 * Testing this class./*from   w ww  .  j a v  a  2  s  . com*/
 * 
 * @param args
 *          Not used.
 */
public static void main(String[] args) {
    // This proves that there are 912 days between the two major
    // terrorist attacks, not 911 as is common knowledge.
    Day september11 = new Day(2001, Calendar.SEPTEMBER, 11);
    Day march11 = new Day(2004, Calendar.MARCH, 11);
    System.out.println(september11.daysBetween(march11));

    // This proves that Kennedy was president for 1037 days,
    // not 1000 as is the popular belief nor 1036 which is the
    // bluffers reply. Nerds knows when to add one...
    Day precidency = new Day(1961, Calendar.JANUARY, 20);
    Day assasination = new Day(1963, Calendar.NOVEMBER, 22);
    System.out.println(precidency.daysBetween(assasination) + 1);

    // Niel Armstrong walked the moon on a Sunday
    Day nielOnMoon = new Day(1969, Calendar.JULY, 20);
    System.out.println(nielOnMoon.getDayNumberOfWeek());

    // Find last tuesdays for 2005
    for (int i = 0; i < 12; i++) {
        Day tuesday = Day.getLastOfMonth(Calendar.TUESDAY, i, 2005);
        System.out.println(tuesday);
    }
}

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

/**
 * @see PortletsController#filterRadiologyOrdersByDateRange(List<RadiologyOrder>, Date, Date)
 * @verifies return list of orders started after given start date but given end date null
 *///  w w  w.j a va 2s  .c  om
@Test
public void filterRadiologyOrdersByDateRange_shouldPopulateModelAndViewWithTableOfOrdersAssociatedWithGivenStartDateButGivenEndDateNull()
        throws Exception {

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

    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(Arrays.asList(mockRadiologyOrder2)));
}

From source file:Time.java

/**
 * Return the 1-based month number of the month of this day. 1 = January, 2 =
 * February and so on./*from w w w. j  av a  2 s .  c  o  m*/
 * 
 * @return Month number of this month
 */
public int getMonthNo() {
    // It is tempting to return getMonth() + 1 but this is conceptually
    // wrong, as Calendar month is an enumeration and the values are tags
    // only and can be anything.
    switch (getMonth()) {
    case Calendar.JANUARY:
        return 1;
    case Calendar.FEBRUARY:
        return 2;
    case Calendar.MARCH:
        return 3;
    case Calendar.APRIL:
        return 4;
    case Calendar.MAY:
        return 5;
    case Calendar.JUNE:
        return 6;
    case Calendar.JULY:
        return 7;
    case Calendar.AUGUST:
        return 8;
    case Calendar.SEPTEMBER:
        return 9;
    case Calendar.OCTOBER:
        return 10;
    case Calendar.NOVEMBER:
        return 11;
    case Calendar.DECEMBER:
        return 12;
    }

    // This will never happen
    return 0;
}

From source file:org.apache.james.protocols.imap.utils.DecoderUtilsTest.java

@Test
public void testDecodeMonth() throws Exception {
    assertEquals(Calendar.JANUARY, DecoderUtils.decodeMonth('J', 'A', 'N'));
    assertEquals(Calendar.JANUARY, DecoderUtils.decodeMonth('j', 'a', 'n'));
    assertEquals(Calendar.FEBRUARY, DecoderUtils.decodeMonth('F', 'E', 'B'));
    assertEquals(Calendar.FEBRUARY, DecoderUtils.decodeMonth('f', 'e', 'b'));
    assertEquals(Calendar.MARCH, DecoderUtils.decodeMonth('M', 'A', 'R'));
    assertEquals(Calendar.MARCH, DecoderUtils.decodeMonth('m', 'a', 'r'));
    assertEquals(Calendar.APRIL, DecoderUtils.decodeMonth('A', 'P', 'R'));
    assertEquals(Calendar.APRIL, DecoderUtils.decodeMonth('a', 'p', 'r'));
    assertEquals(Calendar.MAY, DecoderUtils.decodeMonth('M', 'A', 'Y'));
    assertEquals(Calendar.MAY, DecoderUtils.decodeMonth('m', 'a', 'y'));
    assertEquals(Calendar.JUNE, DecoderUtils.decodeMonth('J', 'U', 'N'));
    assertEquals(Calendar.JUNE, DecoderUtils.decodeMonth('j', 'u', 'n'));
    assertEquals(Calendar.JULY, DecoderUtils.decodeMonth('J', 'U', 'L'));
    assertEquals(Calendar.JULY, DecoderUtils.decodeMonth('j', 'u', 'l'));
    assertEquals(Calendar.AUGUST, DecoderUtils.decodeMonth('A', 'U', 'G'));
    assertEquals(Calendar.AUGUST, DecoderUtils.decodeMonth('a', 'u', 'g'));
    assertEquals(Calendar.SEPTEMBER, DecoderUtils.decodeMonth('S', 'E', 'P'));
    assertEquals(Calendar.SEPTEMBER, DecoderUtils.decodeMonth('s', 'e', 'p'));
    assertEquals(Calendar.OCTOBER, DecoderUtils.decodeMonth('O', 'C', 'T'));
    assertEquals(Calendar.OCTOBER, DecoderUtils.decodeMonth('o', 'c', 't'));
    assertEquals(Calendar.NOVEMBER, DecoderUtils.decodeMonth('N', 'O', 'V'));
    assertEquals(Calendar.NOVEMBER, DecoderUtils.decodeMonth('n', 'o', 'v'));
    assertEquals(Calendar.DECEMBER, DecoderUtils.decodeMonth('D', 'E', 'C'));
    assertEquals(Calendar.DECEMBER, DecoderUtils.decodeMonth('d', 'e', 'c'));
}

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

/**
 * @see PortletsController#filterRadiologyOrdersByDateRange(List<RadiologyOrder>, Date, Date)
 * @verifies return list of orders started before given end date but given start date null
 *///from   w ww  .j a  v  a2 s  .c  om
@Test
public void filterRadiologyOrdersByDateRange_shouldReturnListOfOrdersAssociatedWithGivenEndDateButGivenStartDateNull()
        throws Exception {

    //given
    Date startDate = null;
    Date endDate = new GregorianCalendar(2015, Calendar.MARCH, 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(Arrays.asList(mockRadiologyOrder1)));
}