List of usage examples for java.util Calendar JULY
int JULY
To view the source code for java.util Calendar JULY.
Click Source Link
From source file:org.eclipse.ecr.core.storage.sql.TestSQLBackend.java
public void testBasics() throws Exception { Session session = repository.getConnection(); Node root = session.getRootNode(); Node nodea = session.addChildNode(root, "foo", null, "TestDoc", false); nodea.setSimpleProperty("tst:title", "hello world"); nodea.setSimpleProperty("tst:rate", Double.valueOf(1.5)); nodea.setSimpleProperty("tst:count", Long.valueOf(123456789)); Calendar cal = new GregorianCalendar(2008, Calendar.JULY, 14, 12, 34, 56); nodea.setSimpleProperty("tst:created", cal); nodea.setCollectionProperty("tst:subjects", new String[] { "a", "b", "c" }); nodea.setCollectionProperty("tst:tags", new String[] { "1", "2" }); assertEquals("hello world", nodea.getSimpleProperty("tst:title").getString()); assertEquals(Double.valueOf(1.5), nodea.getSimpleProperty("tst:rate").getValue()); assertEquals(Long.valueOf(123456789), nodea.getSimpleProperty("tst:count").getValue()); assertNotNull(nodea.getSimpleProperty("tst:created").getValue()); String[] subjects = nodea.getCollectionProperty("tst:subjects").getStrings(); String[] tags = nodea.getCollectionProperty("tst:tags").getStrings(); assertEquals(Arrays.asList("a", "b", "c"), Arrays.asList(subjects)); assertEquals(Arrays.asList("1", "2"), Arrays.asList(tags)); session.save();/*w w w . j a va2s .c o m*/ // now modify a property and re-save nodea.setSimpleProperty("tst:title", "another"); nodea.setSimpleProperty("tst:rate", Double.valueOf(3.14)); nodea.setSimpleProperty("tst:count", Long.valueOf(1234567891234L)); nodea.setCollectionProperty("tst:subjects", new String[] { "z", "c" }); nodea.setCollectionProperty("tst:tags", new String[] { "3" }); session.save(); // again nodea.setSimpleProperty("tst:created", null); session.save(); // check the logs to see that the following doesn't do anything because // the value is unchanged since the last save (UPDATE optimizations) nodea.setSimpleProperty("tst:title", "blah"); nodea.setSimpleProperty("tst:title", "another"); session.save(); // now read from another session session.close(); session = repository.getConnection(); root = session.getRootNode(); assertNotNull(root); nodea = session.getChildNode(root, "foo", false); assertEquals("another", nodea.getSimpleProperty("tst:title").getString()); assertEquals(Double.valueOf(3.14), nodea.getSimpleProperty("tst:rate").getValue()); assertEquals(Long.valueOf(1234567891234L), nodea.getSimpleProperty("tst:count").getValue()); subjects = nodea.getCollectionProperty("tst:subjects").getStrings(); tags = nodea.getCollectionProperty("tst:tags").getStrings(); assertEquals(Arrays.asList("z", "c"), Arrays.asList(subjects)); assertEquals(Arrays.asList("3"), Arrays.asList(tags)); // delete the node // session.removeNode(nodea); // session.save(); }
From source file:org.nuxeo.ecm.core.TestSQLRepositoryAPI.java
@Test public void testBasics() throws Exception { DocumentModel root = session.getRootDocument(); DocumentModel child = new DocumentModelImpl("/", "domain", "MyDocType"); child = session.createDocument(child); session.save();/*from ww w. j a v a2s. c om*/ child.setProperty("dublincore", "title", "The title"); // use local tz Calendar cal = new GregorianCalendar(2008, Calendar.JULY, 14, 12, 34, 56); child.setProperty("dublincore", "modified", cal); session.saveDocument(child); session.save(); // ----- new session ----- reopenSession(); // root = session.getRootDocument(); child = session.getChild(root.getRef(), "domain"); String title = (String) child.getProperty("dublincore", "title"); assertEquals("The title", title); String description = (String) child.getProperty("dublincore", "description"); assertNull(description); Calendar modified = (Calendar) child.getProperty("dublincore", "modified"); assertEquals(cal, modified); }
From source file:org.jfree.data.time.QuarterTest.java
/** * Some checks for the getStart() method. *//*from w w w. j a va 2s .com*/ @Test public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JULY, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); Quarter q = new Quarter(3, 2006); assertEquals(cal.getTime(), q.getStart()); Locale.setDefault(saved); }
From source file:org.nuxeo.client.test.TestRepository.java
@Test public void itCanManagePermissions() { // ** CREATION **/ // First Check Document folder = nuxeoClient.repository().fetchDocumentByPath("/folder_2"); ACP acp = folder.fetchPermissions(); assertTrue(acp.getAcls().size() != 0); assertEquals(1, acp.getAcls().size()); assertEquals(2, acp.getAcls().get(0).getAces().size()); assertEquals("inherited", acp.getAcls().get(0).getName()); // Settings//from w ww . j av a 2 s .c om GregorianCalendar begin = new GregorianCalendar(2015, Calendar.JUNE, 20, 12, 34, 56); GregorianCalendar end = new GregorianCalendar(2015, Calendar.JULY, 14, 12, 34, 56); ACE ace = new ACE(); ace.setUsername("user0"); ace.setPermission("Write"); ace.setCreator("Administrator"); ace.setBegin(begin); ace.setEnd(end); ace.setBlockInheritance(true); folder.addPermission(ace); // Final Check folder = nuxeoClient.repository().fetchDocumentByPath("/folder_2"); acp = folder.fetchPermissions(); assertTrue(acp.getAcls().size() != 0); assertEquals(1, acp.getAcls().size()); assertEquals(4, acp.getAcls().get(0).getAces().size()); assertEquals("local", acp.getAcls().get(0).getName()); // ** DELETION **/ folder.removePermission("user0"); // Final Check folder = nuxeoClient.repository().fetchDocumentByPath("/folder_2"); acp = folder.fetchPermissions(); assertTrue(acp.getAcls().size() != 0); assertEquals(1, acp.getAcls().size()); assertEquals(3, acp.getAcls().get(0).getAces().size()); assertEquals("local", acp.getAcls().get(0).getName()); }
From source file:org.openmrs.module.clinicalsummary.web.controller.utils.ExtendedData.java
public String generatePatientData() { // create the string holder StringBuilder builder = new StringBuilder(); // append the initial identifier PatientIdentifier patientIdentifier = patient.getPatientIdentifier(); String identifier = StringUtils.EMPTY; if (patientIdentifier != null) identifier = patientIdentifier.getIdentifier(); builder.append(identifier).append(FIELD_SEPARATOR); // append the patient internal id builder.append(patient.getPatientId()).append(FIELD_SEPARATOR); // append the patient names PersonName patientName = getPatient().getPersonName(); String name = StringUtils.EMPTY; if (patientName != null) name = patientName.getFullName(); builder.append(name).append(FIELD_SEPARATOR); // append the patient age builder.append(patient.getAge()).append(FIELD_SEPARATOR); // append the gender builder.append(getPatient().getGender()).append(FIELD_SEPARATOR); // append initial encounter date Encounter initialEncounter = getInitialEncounter(); String initialEncounterDatetime = StringUtils.EMPTY; if (initialEncounter != null) initialEncounterDatetime = Context.getDateFormat().format(initialEncounter.getEncounterDatetime()); builder.append(initialEncounterDatetime).append(FIELD_SEPARATOR); // append the primary clinic Location primaryClinic = getPrimaryClinic(); String primaryClinicName = StringUtils.EMPTY; if (primaryClinic != null) primaryClinicName = primaryClinic.getName(); builder.append(primaryClinicName).append(FIELD_SEPARATOR); // append visit count to module 1 Location location = Context.getLocationService().getLocation("MTRH Module 1"); List<Encounter> encountersForLocation = searchVisitCountForLocation(location); builder.append(encountersForLocation.size()).append(FIELD_SEPARATOR); // append visit count to module 2 location = Context.getLocationService().getLocation("MTRH Module 2"); encountersForLocation = searchVisitCountForLocation(location); builder.append(encountersForLocation.size()).append(FIELD_SEPARATOR); // append visit count to module 2 location = Context.getLocationService().getLocation("MTRH Module 3"); encountersForLocation = searchVisitCountForLocation(location); builder.append(encountersForLocation.size()).append(FIELD_SEPARATOR); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, 2011); calendar.set(Calendar.MONTH, Calendar.JULY); calendar.set(Calendar.DATE, 1); Date enrollmentDate = calendar.getTime(); Encounter enrollmentEncounter = searchEncounterBeforeReferenceDate(enrollmentDate); if (enrollmentEncounter != null) { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put(EvaluableConstants.OBS_ENCOUNTER, Arrays.asList(enrollmentEncounter)); EvaluatorService evaluatorService = Context.getService(EvaluatorService.class); Result result = evaluatorService.evaluate(patient, AntiRetroViralRule.TOKEN, parameters); String onMedication = String.valueOf(Boolean.FALSE); if (CollectionUtils.isEmpty(result)) onMedication = String.valueOf(Boolean.TRUE); builder.append(onMedication).append(FIELD_SEPARATOR); }/*from w w w. j a v a 2 s. com*/ for (Concept concept : getObservationsByConcept().keySet()) { Obs obs = searchObservationBeforeReferenceDate(concept, enrollmentDate); String obsConceptName = StringUtils.EMPTY; if (concept != null) obsConceptName = concept.getName(Context.getLocale()).getName(); builder.append(obsConceptName).append(FIELD_SEPARATOR); String obsId = StringUtils.EMPTY; if (obs != null) obsId = String.valueOf(obs.getObsId()); builder.append(obsId).append(FIELD_SEPARATOR); String obsDatetime = StringUtils.EMPTY; if (obs != null) obsDatetime = Context.getDateFormat().format(obs.getObsDatetime()); builder.append(obsDatetime).append(FIELD_SEPARATOR); String obsValue = StringUtils.EMPTY; if (obs != null) obsValue = obs.getValueAsString(Context.getLocale()); builder.append(obsValue).append(FIELD_SEPARATOR); } return builder.toString(); }
From source file:Time.java
/** * Testing this class.//from ww w. j av a2 s . co m * * @param args * Not used. */ public static void main(String[] args) { // This proves that there are 912 days between the two major // terrorist attacks, not 911 as is common knowledge. Day september11 = new Day(2001, Calendar.SEPTEMBER, 11); Day march11 = new Day(2004, Calendar.MARCH, 11); System.out.println(september11.daysBetween(march11)); // This proves that Kennedy was president for 1037 days, // not 1000 as is the popular belief nor 1036 which is the // bluffers reply. Nerds knows when to add one... Day precidency = new Day(1961, Calendar.JANUARY, 20); Day assasination = new Day(1963, Calendar.NOVEMBER, 22); System.out.println(precidency.daysBetween(assasination) + 1); // Niel Armstrong walked the moon on a Sunday Day nielOnMoon = new Day(1969, Calendar.JULY, 20); System.out.println(nielOnMoon.getDayNumberOfWeek()); // Find last tuesdays for 2005 for (int i = 0; i < 12; i++) { Day tuesday = Day.getLastOfMonth(Calendar.TUESDAY, i, 2005); System.out.println(tuesday); } }
From source file:Time.java
/** * Return the 1-based month number of the month of this day. 1 = January, 2 = * February and so on.//from w w w.jav a 2 s. c om * * @return Month number of this month */ public int getMonthNo() { // It is tempting to return getMonth() + 1 but this is conceptually // wrong, as Calendar month is an enumeration and the values are tags // only and can be anything. switch (getMonth()) { case Calendar.JANUARY: return 1; case Calendar.FEBRUARY: return 2; case Calendar.MARCH: return 3; case Calendar.APRIL: return 4; case Calendar.MAY: return 5; case Calendar.JUNE: return 6; case Calendar.JULY: return 7; case Calendar.AUGUST: return 8; case Calendar.SEPTEMBER: return 9; case Calendar.OCTOBER: return 10; case Calendar.NOVEMBER: return 11; case Calendar.DECEMBER: return 12; } // This will never happen return 0; }
From source file:org.apache.james.protocols.imap.utils.DecoderUtilsTest.java
@Test public void testDecodeMonth() throws Exception { assertEquals(Calendar.JANUARY, DecoderUtils.decodeMonth('J', 'A', 'N')); assertEquals(Calendar.JANUARY, DecoderUtils.decodeMonth('j', 'a', 'n')); assertEquals(Calendar.FEBRUARY, DecoderUtils.decodeMonth('F', 'E', 'B')); assertEquals(Calendar.FEBRUARY, DecoderUtils.decodeMonth('f', 'e', 'b')); assertEquals(Calendar.MARCH, DecoderUtils.decodeMonth('M', 'A', 'R')); assertEquals(Calendar.MARCH, DecoderUtils.decodeMonth('m', 'a', 'r')); assertEquals(Calendar.APRIL, DecoderUtils.decodeMonth('A', 'P', 'R')); assertEquals(Calendar.APRIL, DecoderUtils.decodeMonth('a', 'p', 'r')); assertEquals(Calendar.MAY, DecoderUtils.decodeMonth('M', 'A', 'Y')); assertEquals(Calendar.MAY, DecoderUtils.decodeMonth('m', 'a', 'y')); assertEquals(Calendar.JUNE, DecoderUtils.decodeMonth('J', 'U', 'N')); assertEquals(Calendar.JUNE, DecoderUtils.decodeMonth('j', 'u', 'n')); assertEquals(Calendar.JULY, DecoderUtils.decodeMonth('J', 'U', 'L')); assertEquals(Calendar.JULY, DecoderUtils.decodeMonth('j', 'u', 'l')); assertEquals(Calendar.AUGUST, DecoderUtils.decodeMonth('A', 'U', 'G')); assertEquals(Calendar.AUGUST, DecoderUtils.decodeMonth('a', 'u', 'g')); assertEquals(Calendar.SEPTEMBER, DecoderUtils.decodeMonth('S', 'E', 'P')); assertEquals(Calendar.SEPTEMBER, DecoderUtils.decodeMonth('s', 'e', 'p')); assertEquals(Calendar.OCTOBER, DecoderUtils.decodeMonth('O', 'C', 'T')); assertEquals(Calendar.OCTOBER, DecoderUtils.decodeMonth('o', 'c', 't')); assertEquals(Calendar.NOVEMBER, DecoderUtils.decodeMonth('N', 'O', 'V')); assertEquals(Calendar.NOVEMBER, DecoderUtils.decodeMonth('n', 'o', 'v')); assertEquals(Calendar.DECEMBER, DecoderUtils.decodeMonth('D', 'E', 'C')); assertEquals(Calendar.DECEMBER, DecoderUtils.decodeMonth('d', 'e', 'c')); }
From source file:org.hawkular.alerts.api.model.action.TimeConstraint.java
private int month(String sMonth) { if (isEmpty(sMonth)) { return -1; }/*from w ww . ja v a 2 s . c o m*/ if (sMonth.length() < 3) { return -1; } String prefix = sMonth.substring(0, 3).toLowerCase(); MONTH m = MONTH.fromString(prefix); if (m == null) { return -1; } switch (m) { case JANUARY: return Calendar.JANUARY; case FEBRUARY: return Calendar.FEBRUARY; case MARCH: return Calendar.MARCH; case APRIL: return Calendar.APRIL; case MAY: return Calendar.MAY; case JUNE: return Calendar.JUNE; case JULY: return Calendar.JULY; case AUGUST: return Calendar.AUGUST; case SEPTEMBER: return Calendar.SEPTEMBER; case OCTOBER: return Calendar.OCTOBER; case NOVEMBER: return Calendar.NOVEMBER; case DECEMBER: return Calendar.DECEMBER; default: return -1; } }
From source file:org.nuxeo.ecm.core.storage.sql.TestSQLBackend.java
@Test public void testBasics() throws Exception { Session session = repository.getConnection(); Node root = session.getRootNode(); Node nodea = session.addChildNode(root, "foo", null, "TestDoc", false); nodea.setSimpleProperty("tst:title", "hello world"); nodea.setSimpleProperty("tst:rate", Double.valueOf(1.5)); nodea.setSimpleProperty("tst:count", Long.valueOf(123456789)); Calendar cal = new GregorianCalendar(2008, Calendar.JULY, 14, 12, 34, 56); nodea.setSimpleProperty("tst:created", cal); nodea.setCollectionProperty("tst:subjects", new String[] { "a", "b", "c" }); nodea.setCollectionProperty("tst:tags", new String[] { "1", "2" }); assertEquals("hello world", nodea.getSimpleProperty("tst:title").getString()); assertEquals(Double.valueOf(1.5), nodea.getSimpleProperty("tst:rate").getValue()); assertEquals(Long.valueOf(123456789), nodea.getSimpleProperty("tst:count").getValue()); assertNotNull(nodea.getSimpleProperty("tst:created").getValue()); String[] subjects = nodea.getCollectionProperty("tst:subjects").getStrings(); String[] tags = nodea.getCollectionProperty("tst:tags").getStrings(); assertEquals(Arrays.asList("a", "b", "c"), Arrays.asList(subjects)); assertEquals(Arrays.asList("1", "2"), Arrays.asList(tags)); session.save();/*www . j a v a 2 s . c o m*/ // now modify a property and re-save nodea.setSimpleProperty("tst:title", "another"); nodea.setSimpleProperty("tst:rate", Double.valueOf(3.14)); nodea.setSimpleProperty("tst:count", Long.valueOf(1234567891234L)); nodea.setCollectionProperty("tst:subjects", new String[] { "z", "c" }); nodea.setCollectionProperty("tst:tags", new String[] { "3" }); session.save(); // again nodea.setSimpleProperty("tst:created", null); session.save(); // check the logs to see that the following doesn't do anything because // the value is unchanged since the last save (UPDATE optimizations) nodea.setSimpleProperty("tst:title", "blah"); nodea.setSimpleProperty("tst:title", "another"); session.save(); // now read from another session session.close(); session = repository.getConnection(); root = session.getRootNode(); assertNotNull(root); nodea = session.getChildNode(root, "foo", false); assertEquals("another", nodea.getSimpleProperty("tst:title").getString()); assertEquals(Double.valueOf(3.14), nodea.getSimpleProperty("tst:rate").getValue()); assertEquals(Long.valueOf(1234567891234L), nodea.getSimpleProperty("tst:count").getValue()); subjects = nodea.getCollectionProperty("tst:subjects").getStrings(); tags = nodea.getCollectionProperty("tst:tags").getStrings(); assertEquals(Arrays.asList("z", "c"), Arrays.asList(subjects)); assertEquals(Arrays.asList("3"), Arrays.asList(tags)); // delete the node // session.removeNode(nodea); // session.save(); }