Example usage for java.util Calendar MAY

List of usage examples for java.util Calendar MAY

Introduction

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

Prototype

int MAY

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

Click Source Link

Document

Value of the #MONTH field indicating the fifth 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
 *///from  www. jav a 2  s  .c om
@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.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverterTest.java

/** Verifies that Zulu time zone is valid in ISO 8601 date. */
@Test/*from ww  w.  j  av a  2s  .  c o m*/
public void testConvertISODateMetacardAttribute() {
    String dateStr = "2013-05-03T17:25:04Z";
    Serializable ser = CswUnmarshallHelper.convertStringValueToMetacardValue(AttributeFormat.DATE, dateStr);
    assertThat(ser, notNullValue());
    assertThat(Date.class.isAssignableFrom(ser.getClass()), is(true));
    Date date = (Date) ser;
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    cal.setTime(date);
    assertThat(cal.get(Calendar.MONTH), is(Calendar.MAY));
    assertThat(cal.get(Calendar.YEAR), is(2013));
    assertThat(cal.get(Calendar.DAY_OF_MONTH), is(3));
}

From source file:Time.java

/**
 * Return the 1-based month number of the month of this day. 1 = January, 2 =
 * February and so on.// w w w.  j av  a2  s .  co  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:com.stratelia.webactiv.util.DateUtilTest.java

@Test
public void testGetEndDateOfWeekFRBetween2Months() {
    Date dateTest = DateUtil.getEndDateOfWeek(java.sql.Date.valueOf("2013-04-29"), "fr");
    Calendar cal = DateUtil.convert(dateTest);
    assertThat(cal.get(Calendar.YEAR), is(2013));
    assertThat(cal.get(Calendar.MONTH), is(Calendar.MAY));
    assertThat(cal.get(Calendar.DAY_OF_MONTH), is(5));
    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:org.hawkular.alerts.api.model.action.TimeConstraint.java

private int month(String sMonth) {
    if (isEmpty(sMonth)) {
        return -1;
    }/* w  w  w  . j a v  a2 s.  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:io.minio.MinioClientTest.java

@Test
public void testListObjects() throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        XmlPullParserException, MinioException {
    final String body = "<ListBucketResult xmlns=\"http://doc.s3.amazonaws.com/2006-03-01\"><Name>bucket</Name><Prefix></Prefix><Marker></Marker><MaxKeys>1000</MaxKeys><Delimiter></Delimiter><IsTruncated>false</IsTruncated><Contents><Key>key</Key><LastModified>2015-05-05T02:21:15.716Z</LastModified><ETag>\"5eb63bbbe01eeed093cb22bb8f5acdc3\"</ETag><Size>11</Size><StorageClass>STANDARD</StorageClass><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner></Contents><Contents><Key>key2</Key><LastModified>2015-05-05T20:36:17.498Z</LastModified><ETag>\"2a60eaffa7a82804bdc682ce1df6c2d4\"</ETag><Size>1661</Size><StorageClass>STANDARD</StorageClass><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner></Contents></ListBucketResult>";
    MockWebServer server = new MockWebServer();
    MockResponse response = new MockResponse();

    response.addHeader("Date", SUN_29_JUN_2015_22_01_10_GMT);
    response.addHeader(CONTENT_LENGTH, "414");
    response.addHeader(CONTENT_TYPE, "application/xml");
    response.setBody(new Buffer().writeUtf8(body));
    response.setResponseCode(200);/*from w  w w .  j av a  2 s .co  m*/

    server.enqueue(response);
    server.start();

    MinioClient client = new MinioClient(server.url(""));
    Iterator<Result<Item>> objectsInBucket = client.listObjects(BUCKET).iterator();

    Item item = objectsInBucket.next().get();
    assertEquals("key", item.objectName());
    assertEquals(11, item.objectSize());
    assertEquals("STANDARD", item.storageClass());

    Calendar expectedDate = Calendar.getInstance();
    expectedDate.clear();
    expectedDate.setTimeZone(TimeZone.getTimeZone("UTC"));
    expectedDate.set(2015, Calendar.MAY, 5, 2, 21, 15);
    expectedDate.set(Calendar.MILLISECOND, 716);
    assertEquals(expectedDate.getTime(), item.lastModified());

    Owner owner = item.owner();
    assertEquals("minio", owner.id());
    assertEquals("minio", owner.displayName());
}

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:/*from   w  w w  . ja  va  2  s  .c  o  m*/
        throw new IllegalArgumentException("Invalid Month");
    }
}

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:io.minio.MinioClientTest.java

@Test
public void testListBuckets() throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        XmlPullParserException, MinioException, ParseException {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    final String body = "<ListAllMyBucketsResult xmlns=\"http://doc.s3.amazonaws.com/2006-03-01\"><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><Buckets><Bucket><Name>bucket</Name><CreationDate>2015-05-05T20:35:51.410Z</CreationDate></Bucket><Bucket><Name>foo</Name><CreationDate>2015-05-05T20:35:47.170Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>";
    MockWebServer server = new MockWebServer();
    MockResponse response = new MockResponse();

    response.addHeader("Date", SUN_29_JUN_2015_22_01_10_GMT);
    response.addHeader(CONTENT_LENGTH, "351");
    response.addHeader(CONTENT_TYPE, "application/xml");
    response.setBody(new Buffer().writeUtf8(body));
    response.setResponseCode(200);//from w w  w .java2 s.  c  om

    server.enqueue(response);
    server.start();

    MinioClient client = new MinioClient(server.url(""));
    Iterator<Bucket> buckets = client.listBuckets().iterator();

    Bucket bucket = buckets.next();
    assertEquals(BUCKET, bucket.name());
    assertEquals(dateFormat.parse("2015-05-05T20:35:51.410Z"), bucket.creationDate());

    bucket = buckets.next();
    assertEquals("foo", bucket.name());
    assertEquals(dateFormat.parse("2015-05-05T20:35:47.170Z"), bucket.creationDate());

    Calendar expectedDate = Calendar.getInstance();
    expectedDate.clear();
    expectedDate.setTimeZone(TimeZone.getTimeZone("UTC"));
    expectedDate.set(2015, Calendar.MAY, 5, 20, 35, 47);
    expectedDate.set(Calendar.MILLISECOND, 170);
    assertEquals(expectedDate.getTime(), bucket.creationDate());
}