List of usage examples for java.util Calendar JANUARY
int JANUARY
To view the source code for java.util Calendar JANUARY.
Click Source Link
From source file:org.eclipse.ecr.core.storage.sql.TestSQLBackend.java
protected void doTestLocksUpgrade() throws Exception { Session session = repository.getConnection(); String id;/*from w w w .j a v a 2 s .co m*/ Lock lock; // check lock has been upgraded from 'bob:Jan 26, 2011' id = "dddddddd-dddd-dddd-dddd-dddddddddddd"; lock = session.getLock(id); assertNotNull(lock); assertEquals("bob", lock.getOwner()); Calendar expected = new GregorianCalendar(2011, Calendar.JANUARY, 26, 0, 0, 0); assertEquals(expected, lock.getCreated()); // old lock was nulled after unlock id = "11111111-2222-3333-4444-555555555555"; lock = session.getLock(id); assertNull(lock); }
From source file:org.kuali.kra.award.home.Award.java
/** * This method finds the latest final expiration date from the collection of AmnoutInfos * @return The latest final expiration date from the collection of AmnoutInfos. If there are no AmoutInfos, 1/1/1900 is returned *//* w ww. ja v a 2 s . c om*/ public Date findLatestFinalExpirationDate() { Date latestExpDate = new Date(new GregorianCalendar(1900, Calendar.JANUARY, 1).getTimeInMillis()); for (AwardAmountInfo amountInfo : getAwardAmountInfos()) { Date expDate = amountInfo.getFinalExpirationDate(); if (expDate != null && expDate.after(latestExpDate)) { latestExpDate = expDate; } } return latestExpDate; }
From source file:org.motechproject.server.ws.RegistrarServiceTest.java
@Test public void queryUpcomingCare() throws ValidationException { Integer staffId = 1, facilityId = 2, motechId = 3; List<ExpectedEncounter> expectedEncounters = new ArrayList<ExpectedEncounter>(); List<ExpectedObs> expectedObs = new ArrayList<ExpectedObs>(); Calendar calendar = Calendar.getInstance(); Care encounterCare1 = new Care(); encounterCare1.setName("EncounterCare1"); calendar.set(2010, Calendar.APRIL, 4); encounterCare1.setDate(calendar.getTime()); Care encounterCare2 = new Care(); encounterCare2.setName("EncounterCare2"); calendar.set(2010, Calendar.DECEMBER, 12); encounterCare2.setDate(calendar.getTime()); Care obsCare1 = new Care(); obsCare1.setName("ObsCare1"); calendar.set(2010, Calendar.OCTOBER, 10); obsCare1.setDate(calendar.getTime()); Care obsCare2 = new Care(); obsCare2.setName("ObsCare2"); calendar.set(2010, Calendar.JANUARY, 1); obsCare2.setDate(calendar.getTime()); Care[] upcomingCares = { obsCare2, encounterCare1, obsCare1, encounterCare2 }; org.openmrs.Patient patient = new org.openmrs.Patient(1); expect(registrarBean.isValidIdCheckDigit(staffId)).andReturn(true); expect(openmrsBean.getStaffBySystemId(staffId.toString())).andReturn(new User(1)); expect(registrarBean.isValidIdCheckDigit(facilityId)).andReturn(true); expect(registrarBean.getFacilityById(facilityId)).andReturn(new Facility()); expect(registrarBean.isValidMotechIdCheckDigit(motechId)).andReturn(true); expect(openmrsBean.getPatientByMotechId(motechId.toString())).andReturn(patient); expect(patientModelConverter.patientToWebService(eq(patient), eq(true))).andReturn(new Patient()); expect(registrarBean.getUpcomingExpectedEncounters(patient)).andReturn(expectedEncounters); expect(registrarBean.getUpcomingExpectedObs(patient)).andReturn(expectedObs); expect(careModelConverter.upcomingToWebServiceCares(expectedEncounters, expectedObs, false)) .andReturn(upcomingCares);/* w w w.j ava 2 s.co m*/ replay(registrarBean, patientModelConverter, openmrsBean, careModelConverter); Patient wsPatient = regWs.queryUpcomingCare(staffId, facilityId, motechId); verify(registrarBean, patientModelConverter, openmrsBean, careModelConverter); verify(registrarBean, patientModelConverter, openmrsBean, careModelConverter); assertNotNull("Patient result is null", wsPatient); Care[] cares = wsPatient.getCares(); assertNotNull("Patient cares is null", cares); assertEquals(4, cares.length); assertEquals(obsCare2.getName(), cares[0].getName()); assertEquals(obsCare2.getDate(), cares[0].getDate()); assertEquals(encounterCare1.getName(), cares[1].getName()); assertEquals(encounterCare1.getDate(), cares[1].getDate()); assertEquals(obsCare1.getName(), cares[2].getName()); assertEquals(obsCare1.getDate(), cares[2].getDate()); assertEquals(encounterCare2.getName(), cares[3].getName()); assertEquals(encounterCare2.getDate(), cares[3].getDate()); }
From source file:ddf.catalog.source.solr.SolrProviderTest.java
@Test() public void testDateDuring() throws Exception { deleteAllIn(provider);//from w ww . ja v a 2 s.c om DateTime now = new DateTime(); addMetacardWithModifiedDate(now); /** POSITIVE CASE **/ Filter filter = filterBuilder.dateIsDuring(Metacard.MODIFIED, dateBeforeNow(now), dateAfterNow(now)); List<Result> results = getResultsForFilteredQuery(filter); assertEquals(1, results.size()); /** NEGATIVE CASES **/ filter = filterBuilder.dateIsDuring(Metacard.MODIFIED, getCannedTime(1980, Calendar.JANUARY, 1, 3), dateBeforeNow(now)); results = getResultsForFilteredQuery(filter); assertEquals(0, results.size()); filter = filterBuilder.dateIsDuring(Metacard.MODIFIED, dateAfterNow(now), getCannedTime(2035, Calendar.JULY, 23, 46)); results = getResultsForFilteredQuery(filter); assertEquals(0, results.size()); }
From source file:org.nuxeo.ecm.core.TestSQLRepositoryAPI.java
@Test public void testImport() throws Exception { DocumentModel folder = new DocumentModelImpl("/", "folder", "Folder"); folder.setProperty("dublincore", "title", "the title"); folder = session.createDocument(folder); session.save();//from www .j av a 2s. com String folderId = folder.getId(); // create a version by import String id; // versionable String vid; // ver id String pid; // proxy id if (folderId.length() == 36) { id = "aaaaaaaa-1234-1234-1234-fedcba987654"; vid = "12345678-1234-1234-1234-fedcba987654"; pid = "00000000-1234-1234-1234-fedcba987654"; } else { id = "888001"; vid = "777002"; pid = "666003"; } String typeName = "File"; DocumentRef parentRef = null; String name = "foobar"; DocumentModel ver = new DocumentModelImpl((String) null, typeName, vid, new Path(name), null, null, parentRef, null, null, null, null); Calendar vcr = new GregorianCalendar(2009, Calendar.JANUARY, 1, 2, 3, 4); ver.putContextData(CoreSession.IMPORT_VERSION_VERSIONABLE_ID, id); ver.putContextData(CoreSession.IMPORT_VERSION_CREATED, vcr); ver.putContextData(CoreSession.IMPORT_VERSION_LABEL, "v1"); ver.putContextData(CoreSession.IMPORT_VERSION_DESCRIPTION, "v descr"); ver.putContextData(CoreSession.IMPORT_IS_VERSION, Boolean.TRUE); ver.putContextData(CoreSession.IMPORT_VERSION_IS_LATEST, Boolean.TRUE); ver.putContextData(CoreSession.IMPORT_VERSION_IS_LATEST_MAJOR, Boolean.FALSE); ver.putContextData(CoreSession.IMPORT_VERSION_MAJOR, Long.valueOf(3)); ver.putContextData(CoreSession.IMPORT_VERSION_MINOR, Long.valueOf(14)); ver.putContextData(CoreSession.IMPORT_LIFECYCLE_POLICY, "v lcp"); ver.putContextData(CoreSession.IMPORT_LIFECYCLE_STATE, "v lcst"); ver.setProperty("dublincore", "title", "Ver title"); Calendar mod = new GregorianCalendar(2008, Calendar.JULY, 14, 12, 34, 56); ver.setProperty("dublincore", "modified", mod); session.importDocuments(Collections.singletonList(ver)); session.save(); reopenSession(); ver = session.getDocument(new IdRef(vid)); // assertEquals(name, doc.getName()); // no path -> no name... assertEquals("Ver title", ver.getProperty("dublincore", "title")); assertEquals(mod, ver.getProperty("dublincore", "modified")); assertEquals("v lcp", ver.getLifeCyclePolicy()); assertEquals("v lcst", ver.getCurrentLifeCycleState()); assertEquals(Long.valueOf(3), ver.getProperty("uid", "major_version")); assertEquals(Long.valueOf(14), ver.getProperty("uid", "minor_version")); assertTrue(ver.isVersion()); assertFalse(ver.isProxy()); // lookup version by label VersionModel versionModel = new VersionModelImpl(); versionModel.setLabel("v1"); ver = session.getVersion(id, versionModel); assertNotNull(ver); assertEquals(vid, ver.getId()); assertEquals("v descr", versionModel.getDescription()); assertEquals(vcr, versionModel.getCreated()); // create a proxy by import typeName = CoreSession.IMPORT_PROXY_TYPE; parentRef = new IdRef(folderId); name = "myproxy"; DocumentModel proxy = new DocumentModelImpl((String) null, typeName, pid, new Path(name), null, null, parentRef, null, null, null, null); proxy.putContextData(CoreSession.IMPORT_PROXY_TARGET_ID, vid); proxy.putContextData(CoreSession.IMPORT_PROXY_VERSIONABLE_ID, id); session.importDocuments(Collections.singletonList(proxy)); session.save(); reopenSession(); proxy = session.getDocument(new IdRef(pid)); assertEquals(name, proxy.getName()); assertEquals("Ver title", proxy.getProperty("dublincore", "title")); assertEquals(mod, proxy.getProperty("dublincore", "modified")); assertEquals("v lcp", proxy.getLifeCyclePolicy()); assertEquals("v lcst", proxy.getCurrentLifeCycleState()); assertFalse(proxy.isVersion()); assertTrue(proxy.isProxy()); // create a normal doc by import typeName = "File"; parentRef = new IdRef(folderId); name = "mydoc"; DocumentModel doc = new DocumentModelImpl((String) null, typeName, id, new Path(name), null, null, parentRef, null, null, null, null); doc.putContextData(CoreSession.IMPORT_LIFECYCLE_POLICY, "lcp"); doc.putContextData(CoreSession.IMPORT_LIFECYCLE_STATE, "lcst"); Calendar lockCreated = new GregorianCalendar(2011, Calendar.JANUARY, 1, 5, 5, 5); doc.putContextData(CoreSession.IMPORT_LOCK_OWNER, "bob"); doc.putContextData(CoreSession.IMPORT_LOCK_CREATED, lockCreated); doc.putContextData(CoreSession.IMPORT_CHECKED_IN, Boolean.TRUE); doc.putContextData(CoreSession.IMPORT_BASE_VERSION_ID, vid); doc.putContextData(CoreSession.IMPORT_VERSION_MAJOR, Long.valueOf(8)); doc.putContextData(CoreSession.IMPORT_VERSION_MINOR, Long.valueOf(1)); doc.setProperty("dublincore", "title", "Live title"); session.importDocuments(Collections.singletonList(doc)); session.save(); reopenSession(); doc = session.getDocument(new IdRef(id)); assertEquals(name, doc.getName()); assertEquals("Live title", doc.getProperty("dublincore", "title")); assertEquals(folderId, doc.getParentRef().toString()); assertEquals("lcp", doc.getLifeCyclePolicy()); assertEquals("lcst", doc.getCurrentLifeCycleState()); assertEquals(Long.valueOf(8), doc.getProperty("uid", "major_version")); assertEquals(Long.valueOf(1), doc.getProperty("uid", "minor_version")); assertTrue(doc.isLocked()); assertEquals("bob", doc.getLockInfo().getOwner()); assertEquals(lockCreated, doc.getLockInfo().getCreated()); assertFalse(doc.isVersion()); assertFalse(doc.isProxy()); }
From source file:org.nuxeo.ecm.core.TestSQLRepositoryAPI.java
/** * Check that lifecycle and dc:issued can be updated on a version. (Fields defined in * SQLDocumentLive#VERSION_WRITABLE_PROPS). *//*from w w w . j a v a 2 s . c o m*/ @Test public void testVersionUpdatableFields() throws Exception { Calendar cal1 = new GregorianCalendar(2008, Calendar.JULY, 14, 12, 34, 56); Calendar cal2 = new GregorianCalendar(2010, Calendar.JANUARY, 1, 0, 0, 0); Calendar cal3 = new GregorianCalendar(2010, Calendar.APRIL, 11, 11, 11, 11); DocumentModel root = session.getRootDocument(); DocumentModel doc = new DocumentModelImpl(root.getPathAsString(), "doc", "File"); doc = session.createDocument(doc); doc.setProperty("dublincore", "title", "t1"); doc.setProperty("dublincore", "issued", cal1); doc = session.saveDocument(doc); session.checkIn(doc.getRef(), null, null); session.checkOut(doc.getRef()); doc.setProperty("dublincore", "title", "t2"); doc.setProperty("dublincore", "issued", cal2); doc = session.saveDocument(doc); // get version DocumentModel ver = session.getLastDocumentVersion(doc.getRef()); assertTrue(ver.isVersion()); assertEquals("project", ver.getCurrentLifeCycleState()); assertEquals("t1", ver.getProperty("dublincore", "title")); assertEquals(cal1, ver.getProperty("dublincore", "issued")); // change lifecycle ver.followTransition("approve"); // change dc:issued ver.setProperty("dublincore", "issued", cal3); session.saveDocument(ver); session.save(); reopenSession(); doc = session.getDocument(new PathRef("/doc")); ver = session.getLastDocumentVersion(doc.getRef()); assertEquals("t1", ver.getProperty("dublincore", "title")); assertEquals("approved", ver.getCurrentLifeCycleState()); assertEquals(cal3, ver.getProperty("dublincore", "issued")); }
From source file:common.SwingGUI01.java
private void addAgentDialogReset() { addAgentDialogName.setText(""); addAgentDialogBorn.setDate(new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime()); addAgentDialogLevel.setSelectedItem(addAgentDialogLevel.getItemAt(0)); addAgentDialogNote.setText(""); }
From source file:common.SwingGUI01.java
private void addMissionDialogReset() { addMissionDialogName.setText(""); addMissionDialogBeginDate.setDate(new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime()); addMissionDialogEndDate.setDate(new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime()); addMissionDialogDifficulty.setSelectedItem(addAgentDialogLevel.getItemAt(0)); addMissionDialogCapacity.setText(""); addMissionDialogNote.setText(""); }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testDisbursementDateInvalidForRedoIfDisbursementBeforeCustomerActivationDate() throws Exception { Assert.assertFalse(LoanBO.isDibursementDateValidForRedoLoan(new LoanOfferingBO() { @Override/*from w w w .j a v a2 s. c om*/ public Date getStartDate() { return DateUtils.getDate(2008, Calendar.JANUARY, 1); } }, new ClientBO() { @Override public Date getCustomerActivationDate() { return DateUtils.getDate(2008, Calendar.JANUARY, 2); } }, DateUtils.getDate(2008, Calendar.JANUARY, 1))); }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testDisbursementDateInvalidForRedoIfDisbursementBeforeProductStartDate() throws Exception { Assert.assertFalse(LoanBO.isDibursementDateValidForRedoLoan(new LoanOfferingBO() { @Override/*www . j a v a2s. c o m*/ public Date getStartDate() { return DateUtils.getDate(2008, Calendar.JANUARY, 2); } }, new ClientBO() { @Override public Date getCustomerActivationDate() { return DateUtils.getDate(2008, Calendar.JANUARY, 1); } }, DateUtils.getDate(2008, Calendar.JANUARY, 1))); }