List of usage examples for java.util Calendar JUNE
int JUNE
To view the source code for java.util Calendar JUNE.
Click Source Link
From source file:ISO8601DateTimeFormat.java
/** * Write century, year, and months.//from ww w .j a v a 2s . c om * @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:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.EncounterController1_8Test.java
/** * @verifies create a new encounter with obs */// w w w. j a v a 2s. co m @Test public void createEncounter_shouldCreateANewEncounterWithObs() throws Exception { int before = Context.getEncounterService().getAllEncounters(null).size(); SimpleObject post = encounterWithObs(); SimpleObject newEncounter = deserialize(handle(newPostRequest(getURI(), post))); Assert.assertNotNull(newEncounter); Assert.assertEquals(before + 1, Context.getEncounterService().getAllEncounters(null).size()); Util.log("created encounter with obs", newEncounter); List<Map> obs = (List<Map>) newEncounter.get("obs"); Assert.assertEquals(4, obs.size()); Set<String> obsDisplayValues = new HashSet<String>(); for (Map o : obs) { obsDisplayValues.add((String) o.get("display")); } Assert.assertTrue(obsDisplayValues.contains("CIVIL STATUS: MARRIED")); Assert.assertTrue(obsDisplayValues.contains("FAVORITE FOOD, NON-CODED: fried chicken")); Assert.assertTrue(obsDisplayValues.contains("WEIGHT (KG): 70.0")); // obs.getValueAsString() uses application Locale and hence have to do this Calendar cal = Calendar.getInstance(); cal.set(2011, Calendar.JUNE, 21, 0, 0, 0); String format = Format.format(cal.getTime(), Context.getLocale(), FORMAT_TYPE.TIMESTAMP); Assert.assertTrue(obsDisplayValues.contains("DATE OF FOOD ASSISTANCE: " + format)); }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for getting month long description * //w w w .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: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.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:fixio.fixprotocol.fields.FieldFactoryTest.java
@Test public void testValueOfUtcTimestampNoMillis() throws Exception { String value = "19980604-08:03:31"; UTCTimestampField field = FieldFactory.valueOf(FieldType.OrigTime.tag(), value.getBytes(US_ASCII)); assertEquals("tagnum", FieldType.OrigTime.tag(), field.getTagNum()); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); calendar.set(Calendar.YEAR, 1998); calendar.set(Calendar.MONTH, Calendar.JUNE); calendar.set(Calendar.DAY_OF_MONTH, 4); calendar.set(Calendar.HOUR_OF_DAY, 8); calendar.set(Calendar.MINUTE, 3); calendar.set(Calendar.SECOND, 31); calendar.set(Calendar.MILLISECOND, 0); long timeInMillis = calendar.getTimeInMillis(); assertEquals("value", timeInMillis, field.getValue().longValue()); assertEquals("value", timeInMillis, field.timestampMillis()); }
From source file:org.richfaces.component.CalendarComponentTest.java
public void testGetPreloadDateRange() throws Exception { UICalendar calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE); calendar.setLocale(Locale.FRENCH); Calendar calendarObject = Calendar.getInstance(); calendarObject.clear();//from w w w. j av a2 s . c o m calendarObject.set(2007, Calendar.JUNE, 10); calendar.setCurrentDate(calendarObject.getTime()); Date[] range = calendar.getPreloadDateRange(); assertEquals(calendar.getPreloadDateRangeBegin(), range[0]); assertEquals(calendar.getPreloadDateRangeEnd(), range[range.length - 1]); assertEquals(30, range.length); }
From source file:de.blizzy.documentr.web.page.PageControllerTest.java
@Test public void getPageMustReturn304IfNotModified() throws IOException { when(session.getAttribute("authenticationCreationTime")).thenReturn( //$NON-NLS-1$ new GregorianCalendar(2012, Calendar.JUNE, 2).getTime().getTime()); when(request.getDateHeader("If-Modified-Since")).thenReturn( //$NON-NLS-1$ new GregorianCalendar(2012, Calendar.JUNE, 9).getTimeInMillis()); when(request.getSession()).thenReturn(session); when(pageStore.getPageMetadata(eq(PROJECT), eq(BRANCH), eq("nonexistent"))) //$NON-NLS-1$ .thenReturn(new PageMetadata("user", new GregorianCalendar(2012, Calendar.JUNE, 1).getTime(), 123, //$NON-NLS-1$ "commit")); //$NON-NLS-1$ TestPageUtil.clearProjectEditTimes(); SecurityContextHolder.setContext(createSecurityContext(anonymousAuthentication)); String view = pageController.getPage(PROJECT, BRANCH, "nonexistent", model, request, response); //$NON-NLS-1$ SecurityContextHolder.clearContext(); assertTrue(removeViewPrefix(view).startsWith("/error/" + HttpServletResponse.SC_NOT_MODIFIED + "/")); //$NON-NLS-1$ //$NON-NLS-2$ assertForward(view);/* w w w. j a v a2 s .co m*/ }
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 av a 2 s . c o m return seasonDates; }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for getting calendar number of month by month * description//from www.ja v a 2 s . c om * * @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; }