List of usage examples for java.util GregorianCalendar getTime
public final Date getTime()
Date
object representing this Calendar
's time value (millisecond offset from the Epoch"). From source file:cs.gui.stats.PerformanceStats.java
private void updateCurrentMaximumRange(int hour, int day, int month, int year) { // set the initial date to 01/01/2010 GregorianCalendar calendar = new GregorianCalendar(); calendar.set(GregorianCalendar.HOUR_OF_DAY, hour); calendar.set(GregorianCalendar.DAY_OF_MONTH, day); calendar.set(GregorianCalendar.MONTH, month - 1); calendar.set(GregorianCalendar.YEAR, year); Date currentDate = calendar.getTime(); if (scope1 == 0) { dateAxis1.setMaximumDate(currentDate); }/* ww w. j ava 2 s .co m*/ if (scope2 == 0) { dateAxis2.setMaximumDate(currentDate); } if (scope3 == 0) { dateAxis3.setMaximumDate(currentDate); } if (scope4 == 0) { dateAxis4.setMaximumDate(currentDate); } if (scope5 == 0) { dateAxis5.setMaximumDate(currentDate); } }
From source file:nl.nn.adapterframework.extensions.cmis.CmisSender.java
private XmlBuilder getPropertyXml(PropertyData property) { XmlBuilder propertyXml = new XmlBuilder("property"); String name = property.getId(); propertyXml.addAttribute("name", name); Object value = property.getFirstValue(); if (value == null) { propertyXml.addAttribute("isNull", "true"); } else {//from w ww . ja v a 2 s .co m if (value instanceof BigInteger) { BigInteger bi = (BigInteger) property.getFirstValue(); propertyXml.setValue(String.valueOf(bi)); } else if (value instanceof Boolean) { Boolean b = (Boolean) property.getFirstValue(); propertyXml.setValue(String.valueOf(b)); } else if (value instanceof GregorianCalendar) { GregorianCalendar gc = (GregorianCalendar) property.getFirstValue(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); propertyXml.setValue(sdf.format(gc.getTime())); } else { propertyXml.setValue((String) property.getFirstValue()); } } return propertyXml; }
From source file:org.etudes.jforum.repository.ForumRepository.java
/** * Check if category is accessible./* w ww . j ava 2 s. c o m*/ * * @param category category * @return true if access to the category is allowed. */ public static boolean isCategoryAccessible(Category category, int userId) { if (category == null) throw new IllegalArgumentException(); if (JForumUserUtil.isJForumFacilitator(UserDirectoryService.getCurrentUser().getId()) || SecurityService.isSuperUser()) { return true; } // ignore forums with category invalid dates if ((category.getStartDate() != null) && (category.getEndDate() != null)) { if (category.getStartDate().after(category.getEndDate())) { return false; } } if ((category.getStartDate() != null) && (category.getAllowUntilDate() != null)) { if (category.getStartDate().after(category.getAllowUntilDate())) { return false; } } if ((category.getEndDate() != null) && (category.getAllowUntilDate() != null)) { if (category.getEndDate().after(category.getAllowUntilDate())) { return false; } } // for gradable category verify with coursemap access advisor UserSession us = SessionFacade.getUserSession(); JForumService jforumService = (JForumService) ComponentManager .get("org.etudes.api.app.jforum.JForumService"); if (category.isGradeCategory() && jforumService != null) { Boolean checkAccess = jforumService.checkItemAccess(ToolManager.getCurrentPlacement().getContext(), ConfigKeys.CM_ID_CATEGORY + "-" + String.valueOf(category.getId()), us.getSakaiUserId()); if (!checkAccess) { category.setBlocked(true); category.setBlockedByTitle(jforumService.getItemAccessMessage( ToolManager.getCurrentPlacement().getContext(), ConfigKeys.CM_ID_CATEGORY + "-" + String.valueOf(category.getId()), us.getSakaiUserId())); category.setBlockedByDetails(jforumService.getItemAccessDetails( ToolManager.getCurrentPlacement().getContext(), ConfigKeys.CM_ID_CATEGORY + "-" + String.valueOf(category.getId()), us.getSakaiUserId())); } } GregorianCalendar gc = new GregorianCalendar(); Date nowDate = gc.getTime(); // category access dates check if (category.getStartDate() != null) { if (nowDate.getTime() < category.getStartDate().getTime()) { // check forum(s) special access for the user if (category.getForums().size() > 0) { return true; } return false; } } return true; }
From source file:biz.wolschon.finance.jgnucash.panels.TaxReportPanel.java
/** * @param aFile the file to write to/* w ww .j ava 2 s. com*/ * @param aGran the granularity */ private void exportCSV(final File aFile, final ExportGranularities aGran) { //TODO: implement CSV-export FileWriter fw = null; try { fw = new FileWriter(aFile); // write headers List<TransactionSum> sums = mySums; fw.write("day"); for (TransactionSum transactionSum : sums) { fw.write(","); fw.write(transactionSum.getName()); } fw.write("\n"); // write data GregorianCalendar cal = new GregorianCalendar(); int add = aGran.getCalendarConstant(); DateFormat dateFormat = DateFormat.getDateInstance(); //NumberFormat numberFormat = NumberFormat.getInstance(); // we do NOT use getCurrencyInstance because it // contains a locale-specific currency-symbol for (int i = 0; i < 100; i++) { Date maxDate = cal.getTime(); fw.write(dateFormat.format(maxDate)); int transactionsCounted = 0; for (TransactionSum transactionSum : sums) { fw.write(","); try { transactionSum.setMaxDate(maxDate); FixedPointNumber value = transactionSum.getValue(); if (value != null) { //fw.write(numberFormat.format(value)); fw.write(value.toString()); } transactionsCounted += transactionSum.getTransactionsCounted(); } catch (JAXBException e) { LOGGER.error("Error calculating one of the TransactionSums", e); fw.write("ERROR"); } } fw.write("\n"); if (transactionsCounted == 0) { break; // we are walking back in time, // when there are no matching transactions, // all future runs will we a waste of time. // This happens often when add==YEAR } long old = cal.getTimeInMillis(); if (add == GregorianCalendar.MONTH) { cal.set(GregorianCalendar.DAY_OF_MONTH, 1); } if (add == GregorianCalendar.YEAR) { cal.set(GregorianCalendar.DAY_OF_MONTH, 1); cal.set(GregorianCalendar.MONTH, 1); } // usually we are in the middle of a month, // so do not skip the first day of the current // month if (i != 0 || old == cal.getTimeInMillis() || add == GregorianCalendar.DAY_OF_MONTH) { cal.add(add, -1); } } fw.close(); fw = null; } catch (IOException e) { LOGGER.error("cannot write csv-file", e); JOptionPane.showMessageDialog(this, "Cannot write CSV-file\n" + e.getMessage()); } finally { if (fw != null) { try { fw.close(); } catch (IOException e) { LOGGER.error("cannot close csv-file", e); } } for (TransactionSum transactionSum : mySums) { try { transactionSum.setMaxDate(null); } catch (JAXBException e) { LOGGER.error("cannot set maxDate back to it's original value", e); } } } }
From source file:org.modelibra.type.EasyCalendar.java
/** * Gets a date from year, month and day numbers. Hours, minutes, seconds and * milliseconds are set to 0.//from www.jav a2 s .c om * * @param year * year * @param month * month * @param day * day * @return date */ public Date getDate(int year, int month, int day) { // short lived calendar, just for this conversion GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); // months start with 0 calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); Date date = calendar.getTime(); return date; }
From source file:org.apache.tika.parser.exiftool.ExifToolImageParserTest.java
public void testJPEGIPTC() throws Exception { Metadata metadata = new Metadata(); metadata.set(Metadata.CONTENT_TYPE, "image/jpeg"); InputStream stream = getClass().getResourceAsStream("/test-documents/testJPEG_IPTC_EXT.jpg"); parser.parse(stream, new DefaultHandler(), metadata, new ParseContext()); assertEquals("Washington", metadata.get(IPTC.CITY)); assertEquals("United States", metadata.get(IPTC.COUNTRY)); assertEquals("US", metadata.get(IPTC.COUNTRY_CODE)); assertEquals(/*from www . j a v a 2 s . co m*/ "A stream bank in Rock Creek Park Washington DC during a photo bike tour with ASPP DC/South chapter.", metadata.get(IPTC.DESCRIPTION)); assertEquals( "A stream bank in Rock Creek Park Washington DC during a photo bike tour with ASPP DC/South chapter.", metadata.get(Metadata.DESCRIPTION)); assertEquals("Rock Creek Park", metadata.get(IPTC.HEADLINE)); assertEquals("Downstream", metadata.get(Metadata.TITLE)); assertEquals("intellectual genre", metadata.get(IPTC.INTELLECTUAL_GENRE)); List<String> iptcKeywords = Arrays.asList(metadata.getValues(IPTC.KEYWORDS)); assertTrue(iptcKeywords.contains("stream")); assertTrue(iptcKeywords.contains("park")); assertTrue(iptcKeywords.contains("bank")); assertEquals(5, iptcKeywords.size()); List<String> tikaKeywords = Arrays.asList(metadata.getValues(Metadata.KEYWORDS)); assertTrue(Arrays.toString(tikaKeywords.toArray()).contains("stream")); assertTrue(Arrays.toString(tikaKeywords.toArray()).contains("park")); assertTrue(Arrays.toString(tikaKeywords.toArray()).contains("bank")); assertEquals(5, tikaKeywords.size()); assertEquals("DC", metadata.get(IPTC.PROVINCE_OR_STATE)); List<String> iptcSceneCode = Arrays.asList(metadata.getValues(IPTC.SCENE_CODE)); assertEquals(2, iptcSceneCode.size()); assertTrue(Arrays.toString(iptcSceneCode.toArray()).contains("iptc scene 1")); assertTrue(Arrays.toString(iptcSceneCode.toArray()).contains("iptc scene 2")); List<String> iptcSubjectCode = Arrays.asList(metadata.getValues(IPTC.SUBJECT_CODE)); assertEquals(2, iptcSubjectCode.size()); assertTrue(Arrays.toString(iptcSubjectCode.toArray()).contains("iptc subject code 1")); assertTrue(Arrays.toString(iptcSubjectCode.toArray()).contains("iptc subject code 2")); assertEquals("Rock Creek Park", metadata.get(IPTC.SUBLOCATION)); GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.YEAR, 2011); calendar.set(Calendar.MONTH, 7); calendar.set(Calendar.DATE, 31); calendar.set(Calendar.HOUR_OF_DAY, 12); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); assertEquals(calendar.getTime(), metadata.getDate(IPTC.DATE_CREATED)); assertEquals("Ray Gauss II", metadata.get(IPTC.DESCRIPTION_WRITER)); assertEquals("instructions", metadata.get(IPTC.INSTRUCTIONS)); assertEquals("job identifier", metadata.get(IPTC.JOB_ID)); assertEquals("Downstream", metadata.get(IPTC.TITLE)); assertTrue(metadata.get(IPTC.COPYRIGHT_NOTICE).contains("Ray Gauss II")); List<String> creators = Arrays.asList(metadata.getValues(IPTC.CREATOR)); assertTrue(Arrays.toString(creators.toArray()).contains("Ray Gauss II")); assertEquals("DAM Architect", metadata.get(IPTC.CREATORS_JOB_TITLE)); assertEquals("provider", metadata.get(IPTC.CREDIT_LINE)); assertEquals("rights usage terms", metadata.get(IPTC.RIGHTS_USAGE_TERMS)); assertEquals("source", metadata.get(IPTC.SOURCE)); assertEquals("1234 Some Road", metadata.get(IPTC.CONTACT_INFO_ADDRESS)); assertEquals("Atlanta", metadata.get(IPTC.CONTACT_INFO_CITY)); assertEquals("US", metadata.get(IPTC.CONTACT_INFO_COUNTRY)); List<String> ciWorkEmails = Arrays.asList(metadata.getValues(IPTC.CONTACT_INFO_EMAIL)); // Photoshop does not support true multi-value here assertTrue(Arrays.toString(ciWorkEmails.toArray()).contains("info@alfresco.com")); assertTrue(Arrays.toString(ciWorkEmails.toArray()).contains("other@example.com")); List<String> ciWorkTels = Arrays.asList(metadata.getValues(IPTC.CONTACT_INFO_PHONE)); // Photoshop does not support true multi-value here assertTrue(Arrays.toString(ciWorkTels.toArray()).contains("555-1234")); assertTrue(Arrays.toString(ciWorkTels.toArray()).contains("555-4321")); assertEquals("30339", metadata.get(IPTC.CONTACT_INFO_POSTAL_CODE)); assertEquals("GA", metadata.get(IPTC.CONTACT_INFO_STATE_PROVINCE)); List<String> ciWorkUrls = Arrays.asList(metadata.getValues(IPTC.CONTACT_INFO_WEB_URL)); // Photoshop does not support true multi-value here assertTrue(Arrays.toString(ciWorkUrls.toArray()).contains("http://alfresco.com")); assertTrue(Arrays.toString(ciWorkUrls.toArray()).contains("http://example.com")); assertEquals("rocky 1 and rocky 2 are big", metadata.get(IPTC.ADDITIONAL_MODEL_INFO)); List<String> orgCodes = Arrays.asList(metadata.getValues(IPTC.ORGANISATION_CODE)); assertEquals(2, orgCodes.size()); assertEquals("ASPP", orgCodes.get(0)); assertEquals("OTHER_ORG", orgCodes.get(1)); // List<String> cvTerms = Arrays.asList(metadata.getValues(IPTC.CONTROLLED_VOCABULARY_TERM)); List<String> modelAges = Arrays.asList(metadata.getValues(IPTC.MODEL_AGE)); assertEquals(2, modelAges.size()); assertEquals("1000", modelAges.get(0)); assertEquals("1001", modelAges.get(1)); List<String> orgNames = Arrays.asList(metadata.getValues(IPTC.ORGANISATION_NAME)); assertEquals(2, orgNames.size()); assertEquals("ASPP", orgNames.get(0)); assertEquals("Other Org", orgNames.get(1)); List<String> peopleShown = Arrays.asList(metadata.getValues(IPTC.PERSON)); assertEquals(2, peopleShown.size()); assertEquals("rocky 1", peopleShown.get(0)); assertEquals("rocky 2", peopleShown.get(1)); assertEquals("http://cv.iptc.org/newscodes/digitalsourcetype/digitalCapture", metadata.get(IPTC.DIGITAL_SOURCE_TYPE)); assertEquals("Photo Bike Tour", metadata.get(IPTC.EVENT)); assertEquals("RGAUSS", metadata.get(IPTC.IMAGE_SUPPLIER_ID)); assertEquals("Ray Gauss II", metadata.get(IPTC.IMAGE_SUPPLIER_NAME)); assertEquals("supplier image ID", metadata.get(IPTC.IMAGE_SUPPLIER_IMAGE_ID)); assertEquals("3456", metadata.get(IPTC.MAX_AVAIL_HEIGHT)); assertEquals("5184", metadata.get(IPTC.MAX_AVAIL_WIDTH)); assertEquals("1.2.0", metadata.get(IPTC.PLUS_VERSION)); List<String> copyrightOwnerIds = Arrays.asList(metadata.getValues(IPTC.COPYRIGHT_OWNER_ID)); assertEquals(1, copyrightOwnerIds.size()); assertEquals("RGAUSS", copyrightOwnerIds.get(0)); // assertEquals("", copyrightOwnerIds.get(1)); // TODO: Get ExifTool to preserve empty values List<String> copyrightOwnerNames = Arrays.asList(metadata.getValues(IPTC.COPYRIGHT_OWNER_NAME)); assertEquals(2, copyrightOwnerNames.size()); assertEquals("Ray Gauss II", copyrightOwnerNames.get(0)); assertEquals("GG", copyrightOwnerNames.get(1)); List<String> imageCreatorIds = Arrays.asList(metadata.getValues(IPTC.IMAGE_CREATOR_ID)); assertEquals(1, imageCreatorIds.size()); assertEquals("RGAUSS", imageCreatorIds.get(0)); // assertEquals("", imageCreatorIds.get(1)); // TODO: Get ExifTool to preserve empty values assertTrue(metadata.isMultiValued(IPTC.IMAGE_CREATOR_NAME)); List<String> imageCreatorNames = Arrays.asList(metadata.getValues(IPTC.IMAGE_CREATOR_NAME)); assertEquals(2, imageCreatorNames.size()); assertEquals("Ray Gauss II", imageCreatorNames.get(0)); assertEquals("GG", imageCreatorNames.get(1)); List<String> licensorIds = Arrays.asList(metadata.getValues(IPTC.LICENSOR_ID)); assertEquals("RGAUSS", licensorIds.get(0)); assertTrue(metadata.isMultiValued(IPTC.LICENSOR_NAME)); List<String> licensorNames = Arrays.asList(metadata.getValues(IPTC.LICENSOR_NAME)); assertEquals(2, licensorNames.size()); assertEquals("Ray Gauss II", licensorNames.get(0)); assertEquals("GG", licensorNames.get(1)); // Photoshop does not support licensor addresses, cities, or countries List<String> licensorEmails = Arrays.asList(metadata.getValues(IPTC.LICENSOR_EMAIL)); assertEquals("r@example.com", licensorEmails.get(0)); // assertEquals("", licensorEmails.get(1)); // TODO: Get ExifTool to preserve empty values List<String> licensorTel1 = Arrays.asList(metadata.getValues(IPTC.LICENSOR_TELEPHONE_1)); assertEquals("555-5555", licensorTel1.get(0)); // assertEquals("", licensorTel1.get(1)); // TODO: Get ExifTool to preserve empty values List<String> licensorTel2 = Arrays.asList(metadata.getValues(IPTC.LICENSOR_TELEPHONE_2)); assertEquals("555-4444", licensorTel2.get(0)); // assertEquals("", licensorTel2.get(1)); // TODO: Get ExifTool to preserve empty values List<String> licensorUrls = Arrays.asList(metadata.getValues(IPTC.LICENSOR_URL)); assertEquals("http://rgauss.com", licensorUrls.get(0)); // assertEquals("", licensorUrls.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("Age Unknown", metadata.get(IPTC.MINOR_MODEL_AGE_DISCLOSURE)); List<String> modelReleaseIds = Arrays.asList(metadata.getValues(IPTC.MODEL_RELEASE_ID)); assertEquals("model release id 1", modelReleaseIds.get(0)); assertEquals("model release id 2", modelReleaseIds.get(1)); assertEquals("Not Applicable", metadata.get(IPTC.MODEL_RELEASE_STATUS)); List<String> propertyReleaseIds = Arrays.asList(metadata.getValues(IPTC.PROPERTY_RELEASE_ID)); assertEquals("prop release id 1", propertyReleaseIds.get(0)); assertEquals("prop release id 2", propertyReleaseIds.get(1)); assertEquals("Not Applicable", metadata.get(IPTC.PROPERTY_RELEASE_STATUS)); List<String> aoCopyright = Arrays .asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_COPYRIGHT_NOTICE)); assertEquals("Ray Gauss II", aoCopyright.get(0)); // assertEquals("", aoCopyright.get(1)); // TODO: Get ExifTool to preserve empty values // assertEquals("", aoCopyright.get(2)); // TODO: Get ExifTool to preserve empty values List<String> aoCreator = Arrays.asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_CREATOR)); assertEquals("Mother Nature", aoCreator.get(0)); assertEquals("Man", aoCreator.get(1)); assertEquals("Mother Nature", aoCreator.get(2)); List<String> aoDateCreated = Arrays.asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_DATE_CREATED)); assertEquals("1890:01:01", aoDateCreated.get(0)); // assertEquals("", aoDateCreated.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("1901:02:01", aoDateCreated.get(1)); // assertEquals("", aoDateCreated.get(2)); // TODO: Get ExifTool to preserve empty values List<String> aoSource = Arrays.asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_SOURCE)); assertEquals("National Park Service", aoSource.get(0)); // assertEquals("", aoSource.get(1)); // TODO: Get ExifTool to preserve empty values // assertEquals("", aoSource.get(2)); // TODO: Get ExifTool to preserve empty values List<String> aoSourceInventoryNum = Arrays .asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_SOURCE_INVENTORY_NUMBER)); assertEquals("123456", aoSourceInventoryNum.get(0)); // assertEquals("", aoSourceInventoryNum.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("654321", aoSourceInventoryNum.get(1)); // This should be index 2, TODO: Get ExifTool to preserve empty values List<String> aoSourceTitles = Arrays.asList(metadata.getValues(IPTC.ARTWORK_OR_OBJECT_DETAIL_TITLE)); assertEquals("Rock Creek Stream Bank", aoSourceTitles.get(0)); assertEquals("Pollution", aoSourceTitles.get(1)); assertEquals("Some Tree", aoSourceTitles.get(2)); List<String> locationShownCity = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_CITY)); assertEquals("Washington", locationShownCity.get(0)); // assertEquals("", locationShownCity.get(1)); // TODO: Get ExifTool to preserve empty values List<String> locationShownCountryCode = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_COUNTRY_CODE)); assertEquals("US", locationShownCountryCode.get(0)); // assertEquals("", locationShownCountryCode.get(1)); // TODO: Get ExifTool to preserve empty values List<String> locationShownCountryName = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_COUNTRY_NAME)); assertEquals("United States", locationShownCountryName.get(0)); // assertEquals("", locationShownCountryName.get(1)); // TODO: Get ExifTool to preserve empty values List<String> locationShownState = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_PROVINCE_OR_STATE)); assertEquals("D.C.", locationShownState.get(0)); // assertEquals("", locationShownState.get(1)); // TODO: Get ExifTool to preserve empty values List<String> locationShownSublocation = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_SUBLOCATION)); assertEquals("Rock Creek Park Sub", locationShownSublocation.get(0)); assertEquals("Stream Section", locationShownSublocation.get(1)); List<String> locationShownWorldRegion = Arrays.asList(metadata.getValues(IPTC.LOCATION_SHOWN_WORLD_REGION)); assertEquals("North America", locationShownWorldRegion.get(0)); // assertEquals("", locationShownWorldRegion.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("Washington", metadata.get(IPTC.LOCATION_CREATED_CITY)); assertEquals("US", metadata.get(IPTC.LOCATION_CREATED_COUNTRY_CODE)); assertEquals("United States", metadata.get(IPTC.LOCATION_CREATED_COUNTRY_NAME)); assertEquals("D.C.", metadata.get(IPTC.LOCATION_CREATED_PROVINCE_OR_STATE)); assertEquals("Rock Creek Park", metadata.get(IPTC.LOCATION_CREATED_SUBLOCATION)); assertEquals("North America", metadata.get(IPTC.LOCATION_CREATED_WORLD_REGION)); assertTrue(IPTC.REGISTRY_ENTRY_CREATED_ORGANISATION_ID.isMultiValuePermitted()); assertTrue(metadata.isMultiValued(IPTC.REGISTRY_ENTRY_CREATED_ORGANISATION_ID)); List<String> registryEntryOrgIds = Arrays .asList(metadata.getValues(IPTC.REGISTRY_ENTRY_CREATED_ORGANISATION_ID)); assertEquals(2, registryEntryOrgIds.size()); assertEquals("PLUS", registryEntryOrgIds.get(0)); // assertEquals("", registryEntryOrgIds.get(1)); // TODO: Get ExifTool to preserve empty values assertEquals("ORG 2", registryEntryOrgIds.get(1)); // This should be index 2, TODO: Get ExifTool to preserve empty values assertTrue(IPTC.REGISTRY_ENTRY_CREATED_ORGANISATION_ID.isMultiValuePermitted()); assertTrue(metadata.isMultiValued(IPTC.REGISTRY_ENTRY_CREATED_ITEM_ID)); List<String> registryEntryItemIds = Arrays.asList(metadata.getValues(IPTC.REGISTRY_ENTRY_CREATED_ITEM_ID)); assertEquals(registryEntryItemIds.size(), 3); assertEquals("100-ABC-ABC-555", registryEntryItemIds.get(0)); assertEquals("11223344", registryEntryItemIds.get(1)); assertEquals("55667788", registryEntryItemIds.get(2)); }
From source file:edu.umm.radonc.ca_dash.controllers.HistogramController.java
public HistogramController() { histogram = new BarChartModel(); percentile = 50.0;//from www . j a v a2 s .co m dstats = new SynchronizedDescriptiveStatistics(); endDate = new Date(); interval = ""; binInterval = -1; includeWeekends = false; GregorianCalendar gc = new GregorianCalendar(); ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); Map<String, Object> sessionMap = externalContext.getSessionMap(); if (sessionMap.containsKey("endDate")) { endDate = (Date) sessionMap.get("endDate"); } else { endDate = new Date(); sessionMap.put("endDate", endDate); } if (sessionMap.containsKey("startDate")) { startDate = (Date) sessionMap.get("startDate"); } else { gc.setTime(endDate); gc.add(Calendar.MONTH, -1); startDate = gc.getTime(); sessionMap.put("startDate", startDate); this.interval = "1m"; } selectedFilters = "all-tx"; selectedFacility = new Long(-1); patientsFlag = true; scheduledFlag = false; relativeModeFlag = false; }
From source file:se.inera.axel.shs.broker.messagestore.internal.MongoMessageLogServiceIT.java
@Test(groups = "largeTests") public void listMessagesWithSince() throws Exception { MessageLogService.Filter filter = new MessageLogService.Filter(); Iterable<ShsMessageEntry> iter = messageLogService.listMessages(ShsLabelMaker.DEFAULT_TEST_FROM, filter); List<ShsMessageEntry> list = Lists.newArrayList(iter); int sizeWithoutSince = list.size(); Assert.assertTrue(sizeWithoutSince > 2, "more than 2 messages should exist"); GregorianCalendar yesterDay = new GregorianCalendar(); yesterDay.add(GregorianCalendar.DAY_OF_MONTH, -1); filter.setSince(yesterDay.getTime()); iter = messageLogService.listMessages(ShsLabelMaker.DEFAULT_TEST_FROM, filter); list = Lists.newArrayList(iter);// ww w . jav a 2 s . co m int sizeWithSince = list.size(); assertEquals(sizeWithSince, sizeWithoutSince - 1, "sizeWithSince should be one less than sizeWithoutSince"); }
From source file:org.modelibra.type.EasyCalendar.java
/** * Gets a date time from year, month, day, hour, minute, second numbers. * Milliseconds are set to 0./*w ww.ja v a2 s .co m*/ * * @param year * year * @param month * month * @param day * day * @param hour * hour * @param minute * minute * @param second * second * @return date time */ public Date getDateTime(int year, int month, int day, int hour, int minute, int second) { // short lived calendar, just for this conversion GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); // months start with 0 calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR, hour); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, second); calendar.set(Calendar.MILLISECOND, 0); Date date = calendar.getTime(); return date; }
From source file:cs.stats.gui.StatsCharts.java
private void updateCurrentMaximumRange(int hour, int day, int month, int year) { // set the initial date to 01/01/2010 GregorianCalendar calendar = new GregorianCalendar(); calendar.set(GregorianCalendar.HOUR_OF_DAY, hour); calendar.set(GregorianCalendar.DAY_OF_MONTH, day); calendar.set(GregorianCalendar.MONTH, month); calendar.set(GregorianCalendar.YEAR, year); Date currentDate = calendar.getTime(); if (scope1 == 0) { dateAxis1.setMaximumDate(currentDate); }/*from ww w . j av a 2 s. com*/ if (scope2 == 0) { dateAxis2.setMaximumDate(currentDate); } if (scope3 == 0) { dateAxis3.setMaximumDate(currentDate); } if (scope4 == 0) { dateAxis4.setMaximumDate(currentDate); } if (scope5 == 0) { dateAxis5.setMaximumDate(currentDate); } }