List of usage examples for java.util Calendar FEBRUARY
int FEBRUARY
To view the source code for java.util Calendar FEBRUARY.
Click Source Link
From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java
@Test public void testParseLongShort() throws ParseException { final Calendar cal = Calendar.getInstance(NEW_YORK, Locale.US); cal.clear();//from w w w. ja va2 s . co m cal.set(2003, Calendar.FEBRUARY, 10, 15, 33, 20); cal.set(Calendar.MILLISECOND, 989); cal.setTimeZone(NEW_YORK); DateParser fdf = getInstance("yyyy GGGG MMMM dddd aaaa EEEE HHHH mmmm ssss SSSS ZZZZ", NEW_YORK, Locale.US); assertEquals(cal.getTime(), fdf.parse("2003 AD February 0010 PM Monday 0015 0033 0020 0989 GMT-05:00")); cal.set(Calendar.ERA, GregorianCalendar.BC); final Date parse = fdf.parse("2003 BC February 0010 PM Saturday 0015 0033 0020 0989 GMT-05:00"); assertEquals(cal.getTime(), parse); fdf = getInstance("y G M d a E H m s S Z", NEW_YORK, Locale.US); assertEquals(cal.getTime(), fdf.parse("03 BC 2 10 PM Sat 15 33 20 989 -0500")); cal.set(Calendar.ERA, GregorianCalendar.AD); assertEquals(cal.getTime(), fdf.parse("03 AD 2 10 PM Saturday 15 33 20 989 -0500")); }
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();/* ww w . j a va 2 s . c o 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:org.openmrs.module.radiology.order.RadiologyOrderServiceComponentTest.java
/** * Convenience method to get a RadiologyOrder object with all required values filled in but * which is not yet saved in the database * //from w ww . j ava 2 s . co m * @return RadiologyOrder object that can be saved to the database */ public RadiologyOrder getUnsavedRadiologyOrder() { RadiologyOrder radiologyOrder = new RadiologyOrder(); radiologyOrder.setPatient(patientService.getPatient(PATIENT_ID_WITH_ONLY_ONE_NON_RADIOLOGY_ORDER)); radiologyOrder.setOrderer(providerService.getProviderByIdentifier("1")); radiologyOrder.setConcept(conceptService.getConcept(CONCEPT_ID_FOR_FRACTURE)); radiologyOrder.setInstructions("CT ABDOMEN PANCREAS WITH IV CONTRAST"); Calendar calendar = Calendar.getInstance(); calendar.set(2015, Calendar.FEBRUARY, 4, 14, 35, 0); radiologyOrder.setScheduledDate(calendar.getTime()); radiologyOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE); RadiologyStudy radiologyStudy = new RadiologyStudy(); radiologyStudy.setModality(Modality.CT); radiologyStudy.setScheduledStatus(ScheduledProcedureStepStatus.SCHEDULED); radiologyOrder.setStudy(radiologyStudy); return radiologyOrder; }
From source file:ch.puzzle.itc.mobiliar.business.generator.control.extracted.ResourceDependencyResolverServiceTest.java
@Test public void findMostRelevantResource_after() { // given/* w ww.j ava2s.c o m*/ List<ResourceEntity> resources = new ArrayList<>(); resources.add(r1); resources.add(r2); resources.add(r3); resources.add(r4); Calendar cal = new GregorianCalendar(); cal.set(2004, Calendar.FEBRUARY, 1); Date relevantDate = new Date(cal.getTimeInMillis()); // when ResourceEntity mostRelevantResource = service.findMostRelevantResource(resources, relevantDate); // then assertEquals(r4, mostRelevantResource); }
From source file:ISO8601DateTimeFormat.java
/** * Write century, year, and months.//from w ww . ja 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:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for getting month long description * //from w w w . j a v a 2 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.hl7.HL7ServiceTest.java
/** * @see HL7Service#processHL7Message(Message) */// w w w. j a v a2s . co m @Test @Verifies(value = "should save hl7Message to the database", method = "processHL7Message(Message)") public void processHL7Message_shouldSaveHl7MessageToTheDatabase() throws Exception { executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml"); HL7Service hl7service = Context.getHL7Service(); Message message = hl7service.parseHL7String( "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20080229|||||||||20080212"); Message result = hl7service.processHL7Message(message); Assert.assertNotNull(result); Concept returnVisitDateConcept = new Concept(5096); Calendar cal = Calendar.getInstance(); cal.set(2008, Calendar.FEBRUARY, 29, 0, 0, 0); List<Obs> returnVisitDateObsForPatient3 = Context.getObsService() .getObservationsByPersonAndConcept(new Patient(3), returnVisitDateConcept); assertEquals("There should be a return visit date", 1, returnVisitDateObsForPatient3.size()); }
From source file:it.caladyon.akka.molla.topology.help.Test_StrategistListenerActor_with_TimedListening.java
/** * Arrivo di 3 messaggi dello stesso mittente nello stesso minuto (non dovrebbe capitare nella realta'). *//*w w w. j av a 2 s .c o m*/ @SuppressWarnings("deprecation") @Test public void test_1() { log.info("---- test 1 -------------------------------"); // questo metodo di creazione delle Props e' ripreso da ActorSystemStarter final SpringExt springExtProvider = SpringExtensionProvider.springExtProvider.get(system); final Props props = springExtProvider.props(LISTENER_BEAN_NAME); final TestActorRef<TestTimedListenerActor> ref = TestActorRef.create(system, props, "test_1"); final TestTimedListenerActor actor = ref.underlyingActor(); try { List<Date> rd = new ArrayList<Date>(); List<MessageWrapper> mv = new ArrayList<MessageWrapper>(); List<Future<Object>> f = new ArrayList<Future<Object>>(); int c = 0; rd.add(new Date(2015, Calendar.FEBRUARY, 19, 17, 0, 10)); mv.add(new MessageWrapper(SOURCE1_BEAN_NAME, rd.get(c), "message-" + c)); f.add(ask(ref, mv.get(c), TIMEOUT)); ++c; rd.add(new Date(2015, Calendar.FEBRUARY, 19, 17, 0, 20)); mv.add(new MessageWrapper(SOURCE1_BEAN_NAME, rd.get(c), "message-" + c)); f.add(ask(ref, mv.get(c), TIMEOUT)); ++c; rd.add(new Date(2015, Calendar.FEBRUARY, 19, 17, 0, 30)); mv.add(new MessageWrapper(SOURCE1_BEAN_NAME, rd.get(c), "message-" + c)); f.add(ask(ref, mv.get(c), TIMEOUT)); ++c; try { Thread.sleep(WAIT + 100); } catch (InterruptedException e1) { e1.printStackTrace(); } for (int i = 0; i < f.size(); ++i) { assertTrue("future " + i, f.get(i).isCompleted()); } assertTrue("execution count", actor.getExecCount() == 0); int inputsSize = ((TimedListening) actor.getListening()).inputs.size(); assertTrue("input size: " + inputsSize, inputsSize == 1); } finally { ref.stop(); } }
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 w w. ja v a 2s. 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:agency.AgentManagerImplTest.java
@Test public void testUpdateAgentValidBorn() { //create agents Agent agent = newAgent01();/*from w w w.j av a2s . com*/ Agent agent02 = newAgent02(); manager.createAgent(agent); manager.createAgent(agent02); Agent reference = manager.findAgentById(agent.getId()); assertNotNull("Agent has not been added to the DB", reference); Calendar cal = new GregorianCalendar(1980, Calendar.FEBRUARY, 2); reference.setBorn(cal.getTime()); manager.updateAgent(agent); assertEquals("Error update of agent birth date", cal.getTime(), reference.getBorn()); assertEquals("Error in name attribute while updating agent's birth date", "James Bond", reference.getName()); assertEquals("Error in level attribute while updating agent's birth date", 5, reference.getLevel()); assertEquals("Error in note attribute while updating agent's birth date", "Best agent ever", reference.getNote()); // Check if updates didn't affect other records assertDeepEquals(agent02, manager.findAgentById(agent02.getId())); }