List of usage examples for java.util Calendar MAY
int MAY
To view the source code for java.util Calendar MAY.
Click Source Link
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:es.logongas.encuestas.presentacion.controller.EncuestaController.java
private Curso getCursoFromDate(Date date) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date);//from w w w . j av a2 s .c om int anyoInicioCurso; int anyoActual = gc.get(GregorianCalendar.YEAR); int mesActual = gc.get(GregorianCalendar.MONTH); //A partir de Mayo estamos en el nuevo curso a efectos de las encuestas de matricula if (mesActual >= Calendar.MAY) { anyoInicioCurso = anyoActual; } else { anyoInicioCurso = anyoActual - 1; } CursoDAO cursoDAO = (CursoDAO) daoFactory.getDAO(Curso.class); Curso curso = cursoDAO.getByAnyoInicio(anyoInicioCurso); if (curso == null) { //Creamos un nuevo curso para este ao throw new RuntimeException("No existe el curso que empieza en el ao:" + anyoInicioCurso); } return curso; }
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:// ww w . j av a 2 s . c o m throw new IllegalArgumentException("Invalid Month"); } }
From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java
@Test public void testLang996() throws ParseException { final Calendar expected = Calendar.getInstance(NEW_YORK, Locale.US); expected.clear();//from w ww.j av a 2 s .c o m expected.set(2014, Calendar.MAY, 14); final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US); assertEquals(expected.getTime(), fdp.parse("14may2014")); assertEquals(expected.getTime(), fdp.parse("14MAY2014")); assertEquals(expected.getTime(), fdp.parse("14May2014")); }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.converter.TestCswRecordConverter.java
/** * Verifies that Zulu time zone is valid in ISO 8601 date. *//*from ww w .j a v a2 s.co m*/ @Test public void testConvertISODateMetacardAttribute() { String dateStr = "2013-05-03T17:25:04Z"; Serializable ser = CswUnmarshallHelper.convertStringValueToMetacardValue(AttributeFormat.DATE, dateStr); assertThat(ser, not(nullValue())); 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), equalTo(Calendar.MAY)); assertThat(cal.get(Calendar.YEAR), equalTo(2013)); assertThat(cal.get(Calendar.DAY_OF_MONTH), equalTo(3)); }
From source file:cn.mljia.common.notify.utils.DateUtils.java
/** * ?/*from w w w . j av a2 s. c o m*/ * * @param date * @return */ public static Date[] getSeasonDate(Date date) { Date[] season = new Date[3]; Calendar c = Calendar.getInstance(); c.setTime(date); int nSeason = getSeason(date); if (nSeason == 1) {// c.set(Calendar.MONTH, Calendar.JANUARY); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.FEBRUARY); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.MARCH); season[2] = c.getTime(); } else if (nSeason == 2) {// c.set(Calendar.MONTH, Calendar.APRIL); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.MAY); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.JUNE); season[2] = c.getTime(); } else if (nSeason == 3) {// c.set(Calendar.MONTH, Calendar.JULY); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.AUGUST); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.SEPTEMBER); season[2] = c.getTime(); } else if (nSeason == 4) {// c.set(Calendar.MONTH, Calendar.OCTOBER); season[0] = c.getTime(); c.set(Calendar.MONTH, Calendar.NOVEMBER); season[1] = c.getTime(); c.set(Calendar.MONTH, Calendar.DECEMBER); season[2] = c.getTime(); } return season; }
From source file:io.minio.MinioClientTest.java
@Test public void testSigningKey() throws NoSuchAlgorithmException, InvalidKeyException, IOException, XmlPullParserException, MinioException { MockWebServer server = new MockWebServer(); MockResponse response = new MockResponse(); response.addHeader("Date", SUN_29_JUN_2015_22_01_10_GMT); response.addHeader(CONTENT_LENGTH, "5080"); response.addHeader(CONTENT_TYPE, APPLICATION_OCTET_STREAM); response.addHeader("ETag", "\"a670520d9d36833b3e28d1e4b73cbe22\""); response.addHeader(LAST_MODIFIED, MON_04_MAY_2015_07_58_51_UTC); response.setResponseCode(200);/*w ww . ja v a 2 s.c o m*/ server.enqueue(response); server.start(); // build expected request Calendar expectedDate = Calendar.getInstance(); expectedDate.clear(); expectedDate.setTimeZone(TimeZone.getTimeZone("UTC")); expectedDate.set(2015, Calendar.MAY, 4, 7, 58, 51); String contentType = APPLICATION_OCTET_STREAM; ObjectStat expectedStatInfo = new ObjectStat(BUCKET, "key", expectedDate.getTime(), 5080, "a670520d9d36833b3e28d1e4b73cbe22", contentType); // get request MinioClient client = new MinioClient(server.url(""), "foo", "bar"); ObjectStat objectStatInfo = client.statObject(BUCKET, "key"); assertEquals(expectedStatInfo, objectStatInfo); }
From source file:cn.mljia.common.notify.utils.DateUtils.java
/** * /*from w w w.j av a2 s.co m*/ * 1 2 3 4 * * @param date * @return */ public static int getSeason(Date date) { int season = 0; Calendar c = Calendar.getInstance(); c.setTime(date); int month = c.get(Calendar.MONTH); switch (month) { case Calendar.JANUARY: case Calendar.FEBRUARY: case Calendar.MARCH: season = 1; break; case Calendar.APRIL: case Calendar.MAY: case Calendar.JUNE: season = 2; break; case Calendar.JULY: case Calendar.AUGUST: case Calendar.SEPTEMBER: season = 3; break; case Calendar.OCTOBER: case Calendar.NOVEMBER: case Calendar.DECEMBER: season = 4; break; default: break; } return season; }
From source file:org.kuali.kfs.module.endow.document.service.impl.CurrentTaxLotServiceImpl.java
/** * This method will check the current month and set the calendar to that month * // w ww . jav a 2s . c o m * @param month month to set the calendar, currentDate currentDate * @return calendar calendar is set to the month selected */ protected Calendar setCaledarWithMonth(String month, Date lastPaymentDate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(lastPaymentDate); 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:com.frey.repo.DateUtil.java
/** * ?// w w w . j a v a2 s . c om */ public static int getPassDayOfSeason(Date date) { int day = 0; Date[] seasonDates = getSeasonDate(date); Calendar c = Calendar.getInstance(); c.setTime(date); int month = c.get(Calendar.MONTH); if (month == Calendar.JANUARY || month == Calendar.APRIL || month == Calendar.JULY || month == Calendar.OCTOBER) {// day = getPassDayOfMonth(seasonDates[0]); } else if (month == Calendar.FEBRUARY || month == Calendar.MAY || month == Calendar.AUGUST || month == Calendar.NOVEMBER) {// day = getDayOfMonth(seasonDates[0]) + getPassDayOfMonth(seasonDates[1]); } else if (month == Calendar.MARCH || month == Calendar.JUNE || month == Calendar.SEPTEMBER || month == Calendar.DECEMBER) {// day = getDayOfMonth(seasonDates[0]) + getDayOfMonth(seasonDates[1]) + getPassDayOfMonth(seasonDates[2]); } return day; }