List of usage examples for java.util Calendar APRIL
int APRIL
To view the source code for java.util Calendar APRIL.
Click Source Link
From source file:org.openmrs.module.reporting.common.DateUtilTest.java
@Test @Verifies(value = "should correctly handle daylight savings time", method = "getTimespan(Date,Date,null)") public void getTimespan_shouldCorrectlyHandleDaylightSavingsTime() throws Exception { // USA has daylight saving time. // in 2009 DST started March 8 and ended November 1 Calendar cal = new GregorianCalendar(Locale.US); cal.set(Calendar.YEAR, 2009); cal.set(Calendar.DAY_OF_MONTH, 25); cal.set(Calendar.MONTH, Calendar.FEBRUARY); Date feb25 = cal.getTime();//w ww . j a v a2s . co m cal.set(Calendar.MONTH, Calendar.MARCH); Date mar25 = cal.getTime(); cal.set(Calendar.MONTH, Calendar.APRIL); Date apr25 = cal.getTime(); cal.set(Calendar.MONTH, Calendar.OCTOBER); Date oct25 = cal.getTime(); cal.set(Calendar.MONTH, Calendar.NOVEMBER); Date nov25 = cal.getTime(); cal.set(Calendar.MONTH, Calendar.DECEMBER); Date dec25 = cal.getTime(); testMessage("reporting.dateUtil.oneMonth reporting.dateUtil.ago", DateUtil.getTimespan(mar25, feb25)); testMessage("reporting.dateUtil.oneMonth reporting.dateUtil.ago", DateUtil.getTimespan(apr25, mar25)); testMessage("reporting.dateUtil.oneMonth reporting.dateUtil.ago", DateUtil.getTimespan(nov25, oct25)); testMessage("reporting.dateUtil.oneMonth reporting.dateUtil.ago", DateUtil.getTimespan(dec25, nov25)); }
From source file:com.xing.api.JsonSerializationTest.java
private static void assertCompanies(XingUser user) throws Exception { Company first = buildPrimaryCompany(); Company second = new Company().id("24_abcdef").name("Ninja Ltd.").title("DevOps").tag("NINJA") .url("http://www.ninja-ltd.co.uk").beginDate(new SafeCalendar(2009, Calendar.APRIL)) .endDate(new SafeCalendar(2010, Calendar.JULY)) .industries(//from w w w . j a v a2 s .co m Collections.singletonList(new Industry(220800, "Athletes, organisers and associations"))) .formOfEmployment(FormOfEmployment.OWNER) .discipline(new Discipline("12_05e01e", "IT_AND_SOFTWARE_DEVELOPMENT")); Company third = new Company().id("45_abcdef").title("Wiss. Mitarbeiter").tag("OFFIS") .url("http://www.uni.de").beginDate(new SafeCalendar(2007)).endDate(new SafeCalendar(2008)) .industries(Collections.singletonList(new Industry(20400, "Fashion and textiles"))) .formOfEmployment(FormOfEmployment.PART_TIME_EMPLOYEE) .discipline(new Discipline("9_5e231a", "TEACHING_R_AND_D")); Company forth = new Company().id("176_abcdef").title("TEST NINJA").companySize(CompanySize.SIZE_201_500) .tag("TESTCOMPANY").careerLevel(CareerLevel.ENTRY_LEVEL) .beginDate(new SafeCalendar(1998, Calendar.DECEMBER)).endDate(new SafeCalendar(1999, Calendar.MAY)) .industries( Collections.singletonList(new Industry(220800, "Athletes, organisers and associations"))) .formOfEmployment(FormOfEmployment.INTERN); assertThat(user.professionalExperience().companies()).containsExactly(first, second, third, forth); }
From source file:org.openmrs.module.auditlog.api.AuditLogServiceTest.java
/** * @see {@link AuditLogService#getAuditLogs(java.util.List, java.util.List, java.util.Date, java.util.Date, boolean, Integer, Integer)} *//*from w ww. ja v a 2 s . com*/ @Test @Verifies(value = "should return logs created on or after the specified startDate", method = "getAuditLogs(List<Class<?>>,List<Action>,Date,Date,Integer,Integer)") public void getAuditLogs_shouldReturnLogsCreatedOnOrAfterTheSpecifiedStartDate() throws Exception { executeDataSet(MODULE_TEST_DATA_AUDIT_LOGS); Calendar cal = Calendar.getInstance(); cal.set(2012, Calendar.APRIL, 1, 0, 1, 0); cal.set(Calendar.MILLISECOND, 0); Date startDate = cal.getTime(); assertEquals(3, auditLogService.getAuditLogs(null, null, startDate, null, false, null, null).size()); }
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;// www. ja va 2 s . c o m 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:ISO8601DateTimeFormat.java
/** * Write century, year, and months./*from w w w. j a v a 2 s. c o m*/ * @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.mb.framework.util.DateTimeUtil.java
/** * This method is used for getting month long description * // www . j av a2 s. c om * @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.auditlog.api.AuditLogServiceTest.java
/** * @see {@link AuditLogService#getAuditLogs(java.util.List, java.util.List, java.util.Date, java.util.Date, boolean, Integer, Integer)} *///w ww.j a va 2 s . co m @Test @Verifies(value = "should return logs created on or before the specified endDate", method = "getAuditLogs(List<Class<?>>,List<Action>,Date,Date,Integer,Integer)") public void getAuditLogs_shouldReturnLogsCreatedOnOrBeforeTheSpecifiedEndDate() throws Exception { executeDataSet(MODULE_TEST_DATA_AUDIT_LOGS); Calendar cal = Calendar.getInstance(); cal.set(2012, Calendar.APRIL, 1, 0, 3, 0); cal.set(Calendar.MILLISECOND, 0); Date endDate = cal.getTime(); assertEquals(5, auditLogService.getAuditLogs(null, null, null, endDate, false, null, null).size()); }
From source file:com.gemstone.gemfire.rest.internal.web.controllers.RestAPIsWithSSLDUnitTest.java
public void doPutsInClientCache() { ClientCache cache = GemFireCacheImpl.getInstance(); assertNotNull(cache);//w w w.j ava 2 s .c om 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.openmrs.module.auditlog.api.AuditLogServiceTest.java
/** * @see {@link AuditLogService#getAuditLogs(java.util.List, java.util.List, java.util.Date, java.util.Date, boolean, Integer, Integer)} *//*from ww w .java 2 s.c om*/ @Test @Verifies(value = "should return logs created within the specified start and end dates", method = "getAuditLogs(List<Class<?>>,List<Action>,Date,Date,Integer,Integer)") public void getAuditLogs_shouldReturnLogsCreatedWithinTheSpecifiedStartAndEndDates() throws Exception { executeDataSet(MODULE_TEST_DATA_AUDIT_LOGS); Calendar cal = Calendar.getInstance(); cal.set(Calendar.MILLISECOND, 0); cal.set(2012, Calendar.APRIL, 1, 0, 0, 1); Date startDate = cal.getTime(); cal.set(2012, Calendar.APRIL, 1, 0, 3, 1); Date endDate = cal.getTime(); assertEquals(2, auditLogService.getAuditLogs(null, null, startDate, endDate, false, null, null).size()); }
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.j a v a 2 s. c o m * * @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; }