List of usage examples for java.text DateFormat SHORT
int SHORT
To view the source code for java.text DateFormat SHORT.
Click Source Link
From source file:com.sample.partnerprofile.portlet.JSPPortlet.java
public void processAction(ActionRequest req, ActionResponse res) throws IOException, PortletException { String command = req.getParameter("command"); int id = 0;//from w w w.j ava2 s . c om long userId = 0; userId = PortalUtil.getUserId(req); System.out.println("userId in action request este " + String.valueOf(userId)); try { id = Integer.parseInt(req.getParameter("id")); //userId = Integer.parseInt(req.getParameter("userId")); } catch (Exception e) { } // user relatesd String name = req.getParameter("first_name"); String userLastName = req.getParameter("last_name"); String userCompanyName = req.getParameter("userCompanyName"); String userPositionCompany = req.getParameter("userPositionCompany"); String userMobilePhone = req.getParameter("telephone_user"); String userWorkPhone = req.getParameter("telefax_user"); // company related String partnerDescription = req.getParameter("partnerDescription"); int partnerNumber = 1; if (req.getParameter("partnerNumber") != null) partnerNumber = Integer.parseInt(req.getParameter("partnerNumber")); String telephone = req.getParameter("telephone"); String telefax = req.getParameter("telefax"); String mail = req.getParameter("mail"); String street1 = req.getParameter("street1"); String street2 = req.getParameter("street2"); String zipcode = req.getParameter("zipcode"); String city = req.getParameter("city"); String state_province = req.getParameter("state_province"); String country = req.getParameter("country"); String micrositeAdress = req.getParameter("micrositeAdress"); String company_website = req.getParameter("company_website"); String noemployees = req.getParameter("noemployees"); String geographic_coverage = req.getParameter("geographic_coverage"); String parent_company_name = req.getParameter("parent_company_name"); String country_parent_company = req.getParameter("country_parent_company"); String channel_partner_since = req.getParameter("channel_partner_since"); String primary_business_type = req.getParameter("primary_business_type"); String secondary_business_type = req.getParameter("secondary_business_type"); String sap_solution_focus = req.getParameter("sap_solution_focus"); String industry_micro_vertical_focus = req.getParameter("industry_micro_vertical_focus"); String last_review_Date = req.getParameter("last_review_Date"); String reviewed_by = req.getParameter("reviewed_by"); String profile_added = "";//req.getParameter("profile_added"); String date_updated = "";//req.getParameter("date_updated"); String modified_by = req.getParameter("modified_by"); String[] SAPitems = req.getParameterValues("sap_solution_focus"); String[] industry = req.getParameterValues("industry"); String[] countryCoverage = req.getParameterValues("country_coverage"); //search related String[] SAPitems_search = req.getParameterValues("sap_solution_focus_search"); String industrySearch = req.getParameter("industry_search"); String[] countryCoverage_search = req.getParameterValues("country_coverage_search"); String country_search = req.getParameter("country_search"); String primary_business_type_search = req.getParameter("primary_business_type_search"); try { SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); if (command.equals("add")) { // user // user adress + phone // company CompanyItem companyItem = new CompanyItem(); companyItem.setName(userCompanyName); companyItem.setDescription(partnerDescription); companyItem.setCompanyNo(partnerNumber); companyItem.setCompanyFriendlySite(micrositeAdress); companyItem.setCompanySite(company_website); if (noemployees != null && !noemployees.isEmpty()) companyItem.setCompanyEmpNo(Integer.parseInt(noemployees)); companyItem.setParentCompanyName(parent_company_name); if (channel_partner_since != null && !channel_partner_since.isEmpty()) companyItem.setYear(Integer.parseInt(channel_partner_since)); if (country_parent_company != "") { CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country_parent_company); if (countryItemTemp != null) companyItem.setCountryRegistrationId(countryItemTemp.getId()); } Date tempDate = new Date(); companyItem.setDateUpdated(new Date()); companyItem.setDateLastReview(new Date()); companyItem.setDateUpdated(new Date()); if (last_review_Date != null && !last_review_Date.isEmpty()) { try { tempDate = format.parse(last_review_Date); String value = tempDate.toString(); companyItem.setDateLastReview(tempDate); } catch (ParseException ex) { } } companyItem.setReviewedBy(reviewed_by); companyItem.setModifiedBy(modified_by); companyItem.setCompanyUserId(userId); CompanyItemDAO.addCompanyItem(companyItem); int adressId = companyItem.getAdressId(); AdressItem adressItem = null; if (adressId <= 0) { adressItem = new AdressItem(); adressItem.setCompanyId(companyItem.getId()); adressItem.setStreet1(street1); adressItem.setStreet2(street2); adressItem.setCity(city); adressItem.setZip(zipcode); adressItem.setStateregionname(state_province); adressItem.setMail(mail); // countryId if (country != "") { CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country); adressItem.setCountryId(countryItemTemp.getId()); } AdressItemDAO.addAdressItem(adressItem); companyItem.setAdressId(adressItem.getId()); if (telephone != "") AdressItemDAO.updatePhoneItem(adressItem, telephone, 1); if (telefax != "") AdressItemDAO.updatePhoneItem(adressItem, telefax, 2); AdressItemDAO.updateAdressItem(adressItem); } // Do update in main table CompanyItemDAO.updateCompanyItem(companyItem); //2 . SAP solution focus CompanyUtil.updateCompanySAPSolutionList(companyItem, SAPitems); // 3. Industry CompanyUtil.updateCompanyIndustriesList(companyItem, industry); //4. primary business type -- primary_business_type if (primary_business_type != null) CompanyUtil.updateBusinessType(companyItem, primary_business_type, 1); //5. secondary business type - secondary_business_type if (secondary_business_type != null) CompanyUtil.updateBusinessType(companyItem, secondary_business_type, 2); //6. country coverage if (countryCoverage != null) { for (int loopIndex = 0; loopIndex < countryCoverage.length; loopIndex++) { System.out.println(countryCoverage[loopIndex]); } } CompanyUtil.updateCompanyCountryCoverage(companyItem, countryCoverage); } else if (command.equals("edit")) { //user CompanyItem companyItem = CompanyItemDAO.getCompanyItem(id); companyItem.setName(userCompanyName); companyItem.setDescription(partnerDescription); companyItem.setCompanyNo(partnerNumber); companyItem.setCompanyFriendlySite(micrositeAdress); companyItem.setCompanySite(company_website); if (noemployees != null && !noemployees.isEmpty()) companyItem.setCompanyEmpNo(Integer.parseInt(noemployees)); companyItem.setParentCompanyName(parent_company_name); if (channel_partner_since != null && !channel_partner_since.isEmpty()) companyItem.setYear(Integer.parseInt(channel_partner_since)); if (country_parent_company != "") { CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country_parent_company); if (countryItemTemp != null) companyItem.setCountryRegistrationId(countryItemTemp.getId()); } Date date = new Date(); try { date = format.parse(last_review_Date); } catch (ParseException ex) { } companyItem.setDateLastReview(date); /*try {date = df.parse(profile_added); }catch (ParseException ex){ } companyItem.setDateCreated(date);*/ companyItem.setDateUpdated(new Date()); companyItem.setReviewedBy(reviewed_by); companyItem.setModifiedBy(modified_by); // update childs //1 . adress + phone int adressId = companyItem.getAdressId(); AdressItem adressItem = null; boolean bIsNew = false; if (adressId > 0) { adressItem = AdressItemDAO.getAdressItem(adressId); } else { adressItem = new AdressItem(); bIsNew = true; } if (adressItem != null) { adressItem.setCompanyId(id); adressItem.setStreet1(street1); adressItem.setStreet2(street2); adressItem.setCity(city); adressItem.setZip(zipcode); adressItem.setStateregionname(state_province); adressItem.setMail(mail); // countryId if (country != "") { CountryItem countryItemTemp = CountryItemDAO.getCountryItemByName(country); adressItem.setCountryId(countryItemTemp.getId()); } if (bIsNew) { AdressItemDAO.addAdressItem(adressItem); companyItem.setAdressId(adressItem.getId()); } if (telephone != "") AdressItemDAO.updatePhoneItem(adressItem, telephone, 1); if (telefax != "") AdressItemDAO.updatePhoneItem(adressItem, telefax, 2); AdressItemDAO.updateAdressItem(adressItem); } // Do update in main table CompanyItemDAO.updateCompanyItem(companyItem); //2 . SAP solution focus CompanyUtil.updateCompanySAPSolutionList(companyItem, SAPitems); // 3. Industry CompanyUtil.updateCompanyIndustriesList(companyItem, industry); //4. primary business type -- primary_business_type if (primary_business_type != null) CompanyUtil.updateBusinessType(companyItem, primary_business_type, 1); //5. secondary business type - secondary_business_type if (secondary_business_type != null) CompanyUtil.updateBusinessType(companyItem, secondary_business_type, 2); //6. country coverage CompanyUtil.updateCompanyCountryCoverage(companyItem, countryCoverage); } else if (command.equals("delete")) { CompanyItemDAO.deleteCompanyItem(id); } else if (command.equals("search")) { ; } else if (command.equals("viewall")) { ; } } catch (SQLException sqle) { throw new PortletException(sqle); } }
From source file:org.opencms.scheduler.jobs.CmsPublishScheduledJob.java
/** * @see org.opencms.scheduler.I_CmsScheduledJob#launch(org.opencms.file.CmsObject, java.util.Map) *//*from w w w . ja v a2 s. com*/ @SuppressWarnings("unchecked") public synchronized String launch(CmsObject cms, Map parameters) throws Exception { Date jobStart = new Date(); String finishMessage; String linkcheck = (String) parameters.get(PARAM_LINKCHECK); String jobName = (String) parameters.get(PARAM_JOBNAME); CmsProject project = cms.getRequestContext().getCurrentProject(); CmsLogReport report = new CmsLogReport(cms.getRequestContext().getLocale(), CmsPublishScheduledJob.class); try { // validate links if linkcheck parameter was given if (Boolean.valueOf(linkcheck).booleanValue()) { OpenCms.getPublishManager().validateRelations(cms, OpenCms.getPublishManager().getPublishList(cms), report); } // change lock for the resources if necessary Iterator<String> iter = cms.readProjectResources(project).iterator(); while (iter.hasNext()) { String resource = iter.next(); // get current lock from file CmsLock lock = cms.getLock(resource); // prove is current lock from current but not in current project if ((lock != null) && lock.isInProject(cms.getRequestContext().getCurrentProject()) && !lock.isOwnedBy(cms.getRequestContext().getCurrentUser())) { // file is locked in current project but not by current user // unlock this file cms.changeLock(resource); } } // publish the project, the publish output will be put in the logfile OpenCms.getPublishManager().publishProject(cms, report); OpenCms.getPublishManager().waitWhileRunning(); finishMessage = Messages.get().getBundle().key(Messages.LOG_PUBLISH_FINISHED_1, project.getName()); } catch (CmsException e) { // there was an error, so create an output for the logfile finishMessage = Messages.get().getBundle().key(Messages.LOG_PUBLISH_FAILED_2, project.getName(), e.getMessageContainer().key()); // add error to report report.addError(finishMessage); } finally { //wait for other processes that may add entries to the report long lastTime = report.getLastEntryTime(); long beforeLastTime = 0; while (lastTime != beforeLastTime) { wait(30000); beforeLastTime = lastTime; lastTime = report.getLastEntryTime(); } // delete the job // the job id String jobId = ""; // iterate over all jobs to find the current one Iterator<CmsScheduledJobInfo> iter = OpenCms.getScheduleManager().getJobs().iterator(); while (iter.hasNext()) { CmsScheduledJobInfo jobInfo = iter.next(); // the current job is found with the job name if (jobInfo.getJobName().equals(jobName)) { // get the current job id jobId = jobInfo.getId(); } } // delete the current job OpenCms.getScheduleManager().unscheduleJob(cms, jobId); // send publish notification if (report.hasWarning() || report.hasError()) { try { String userName = (String) parameters.get(PARAM_USER); CmsUser user = cms.readUser(userName); CmsPublishNotification notification = new CmsPublishNotification(cms, user, report); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); notification.addMacro("jobStart", df.format(jobStart)); notification.send(); } catch (Exception e) { LOG.error(Messages.get().getBundle().key(Messages.LOG_PUBLISH_SEND_NOTIFICATION_FAILED_0), e); } } } return finishMessage; }
From source file:org.ambraproject.freemarker.AmbraFreemarkerConfig.java
/** * Constructor that loads the list of css and javascript files and page titles for pages which follow the standard * templates. Creates its own composite configuration by iterating over each of the configs in the config to assemble * a union of pages defined./*from w ww.j av a2s . c o m*/ * * @param configuration Ambra configuration * @throws Exception Exception */ public AmbraFreemarkerConfig(Configuration configuration) throws Exception { if (log.isDebugEnabled()) { log.debug("Creating FreeMarker configuration"); } debug = configuration.getBoolean("struts.devMode"); dirPrefix = configuration.getString("ambra.platform.appContext"); subdirPrefix = configuration.getString("ambra.platform.resourceSubDir"); host = configuration.getString("ambra.platform.host"); casLoginURL = configuration.getString("ambra.services.cas.url.login"); casLogoutURL = configuration.getString("ambra.services.cas.url.logout"); registrationURL = configuration.getString("ambra.services.registration.url.registration"); changePasswordURL = configuration.getString("ambra.services.registration.url.change-password"); changeEmailURL = configuration.getString("ambra.services.registration.url.change-email"); doiResolverURL = configuration.getString("ambra.services.crossref.plos.doiurl"); defaultJournalName = configuration.getString(DEFAULT_JOURNAL_NAME_CONFIG_KEY); journals = new HashMap<String, JournalConfig>(); journalsByIssn = new HashMap<String, JournalConfig>(); orgName = configuration.getString("ambra.platform.name"); feedbackEmail = configuration.getString("ambra.platform.email.feedback"); cache_storage_strong = configuration.getInt("ambra.platform.template_cache.strong", DEFAULT_TEMPLATE_CACHE_STRONG); cache_storage_soft = configuration.getInt("ambra.platform.template_cache.soft", DEFAULT_TEMPLATE_CACHE_SOFT); templateUpdateDelay = configuration.getInt("ambra.platform.template_cache.update_delay", DEFAULT_TEMPLATE_UPDATE_DELAY); String date = configuration.getString("ambra.platform.cisStartDate"); freemarkerProperties = configuration.subset("ambra.platform.freemarker"); nedProfileURL = configuration.getString("ned.profile"); nedRegistrationURL = configuration.getString("ned.registration"); if (date == null) { throw new Exception("Could not find the cisStartDate node in the " + "ambra platform configuration. Make sure the " + "ambra/platform/cisStartDate node exists."); } try { cisStartDate = DateFormat.getDateInstance(DateFormat.SHORT).parse(date); } catch (ParseException ex) { throw new Exception("Could not parse the cisStartDate value of \"" + date + "\" in the ambra platform configuration. Make sure the cisStartDate is in the " + "following format: dd/mm/yyyy", ex); } loadConfig(configuration); processVirtualJournalConfig(configuration); // Now that the "journals" Map exists, index that map by Eissn to populate "journalsByEissn". if (journals.entrySet() != null && journals.entrySet().size() > 0) { for (Entry<String, JournalConfig> e : journals.entrySet()) { JournalConfig j = e.getValue(); journalsByIssn.put(j.getIssn(), j); } } journalUrls = buildUrlMap(journals); journalsUrlsByIssn = buildUrlMap(journalsByIssn); if (log.isTraceEnabled()) { for (Entry<String, JournalConfig> e : journals.entrySet()) { JournalConfig j = e.getValue(); log.trace("Journal: " + e.getKey()); log.trace("Journal url: " + j.getUrl()); log.trace("Default Title: " + j.getDefaultTitle()); log.trace("Default CSS: " + printArray(j.getDefaultCss())); log.trace("Default JavaScript: " + printArray(j.getDefaultCss())); Map<String, String[]> map = j.getCssFiles(); for (Entry<String, String[]> entry : map.entrySet()) { log.trace("PageName: " + entry.getKey()); log.trace("CSS FILES: " + printArray(entry.getValue())); } map = j.getJavaScriptFiles(); for (Entry<String, String[]> entry : map.entrySet()) { log.trace("PageName: " + entry.getKey()); log.trace("JS FILES: " + printArray(entry.getValue())); } for (Entry<String, String> entry : j.getTitles().entrySet()) { log.trace("PageName: " + entry.getKey()); log.trace("Title: " + entry.getValue()); } } log.trace("Dir Prefix: " + dirPrefix); log.trace("SubDir Prefix: " + subdirPrefix); log.trace("Host: " + host); log.trace("Cas url login: " + casLoginURL); log.trace("Case url logout: " + casLogoutURL); log.trace("Registration URL: " + registrationURL); log.trace("Registration Change Pass URL: " + changePasswordURL); log.trace("Registration Change EMail URL: " + changeEmailURL); log.trace("DOI Resolver URL: " + doiResolverURL); log.trace("Default Journal Name: " + defaultJournalName); log.trace("NED Profile URL: " + nedProfileURL); log.trace("NED Registration URL: " + nedRegistrationURL); } if (log.isDebugEnabled()) { log.debug("End FreeMarker Configuration Reading"); } }
From source file:com.sonyericsson.jenkins.plugins.bfa.CauseManagementHudsonTest.java
/** * Verifies that the table on the {@link CauseManagement} page displays all causes with description and that * one of them can be navigated to and a valid edit page for that cause is shown. * * @throws Exception if so./*from w w w. j av a 2 s . c om*/ */ public void testTableViewNavigation() throws Exception { KnowledgeBase kb = PluginImpl.getInstance().getKnowledgeBase(); //Overriding isStatisticsEnabled in order to display all fields on the management page: KnowledgeBase mockKb = spy(kb); when(mockKb.isStatisticsEnabled()).thenReturn(true); Whitebox.setInternalState(PluginImpl.getInstance(), "knowledgeBase", mockKb); List<String> myCategories = new LinkedList<String>(); myCategories.add("myCtegory"); //CS IGNORE MagicNumber FOR NEXT 5 LINES. REASON: TestData. Date endOfWorld = new Date(1356106375000L); Date birthday = new Date(678381175000L); Date millenniumBug = new Date(946681200000L); Date pluginReleased = new Date(1351724400000L); FailureCause cause = new FailureCause(null, "SomeName", "A Description", "Some comment", endOfWorld, myCategories, null, Collections.singletonList(new FailureCauseModification("user", birthday))); cause.addIndication(new BuildLogIndication(".")); kb.addCause(cause); cause = new FailureCause(null, "SomeOtherName", "A Description", "Another comment", millenniumBug, myCategories, null, Collections.singletonList(new FailureCauseModification("user", pluginReleased))); cause.addIndication(new BuildLogIndication(".")); kb.addCause(cause); WebClient web = createWebClient(); HtmlPage page = web.goTo(CauseManagement.URL_NAME); HtmlTable table = (HtmlTable) page.getElementById("failureCausesTable"); Collection<FailureCause> expectedCauses = kb.getShallowCauses(); int rowCount = table.getRowCount(); assertEquals(expectedCauses.size() + 1, rowCount); Iterator<FailureCause> causeIterator = expectedCauses.iterator(); FailureCause firstCause = null; for (int i = 1; i < rowCount; i++) { assertTrue(causeIterator.hasNext()); FailureCause c = causeIterator.next(); HtmlTableRow row = table.getRow(i); String name = row.getCell(NAME_CELL).getTextContent(); String categories = row.getCell(CATEGORY_CELL).getTextContent(); String description = row.getCell(DESCRIPTION_CELL).getTextContent(); String comment = row.getCell(COMMENT_CELL).getTextContent(); String modified = row.getCell(MODIFIED_CELL).getTextContent(); String lastSeen = row.getCell(LAST_SEEN_CELL).getTextContent(); assertEquals(c.getName(), name); assertEquals(c.getCategoriesAsString(), categories); assertEquals(c.getDescription(), description); assertEquals(c.getComment(), comment); assertEquals("Modified date should be visible", DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT) .format(c.getLatestModification().getTime()) + " by user", modified); assertEquals("Last seen date should be visible", DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(c.getLastOccurred()), lastSeen); if (i == 1) { firstCause = c; } } //The table looks ok, now lets see if we can navigate correctly. assertNotNull(firstCause); HtmlAnchor firstCauseLink = (HtmlAnchor) table.getCellAt(1, 0).getFirstChild(); HtmlPage editPage = firstCauseLink.click(); verifyCorrectCauseEditPage(firstCause, editPage); }
From source file:org.kuali.kra.rules.SaveCustomAttributeRule.java
/** * Validates the format/length of custom attribute. * @param customAttribute The custom attribute to validate * @param errorKey The error key on the interface * @return// w ww . java 2s .co m */ private boolean validateAttributeFormat(CustomAttribute customAttribute, CustomAttributeDataType customAttributeDataType, String errorKey) { boolean isValid = true; Integer maxLength = customAttribute.getDataLength(); String attributeValue = customAttribute.getValue(); if ((maxLength != null) && (maxLength.intValue() < attributeValue.length())) { reportError(errorKey, RiceKeyConstants.ERROR_MAX_LENGTH, customAttribute.getLabel(), maxLength.toString()); isValid = false; } final ValidationPattern validationPattern = VALIDATION_CLASSES .get(customAttributeDataType.getDescription()); // if there is no data type matched, then set error ? Pattern validationExpression = validationPattern.getRegexPattern(); String validFormat = getValidFormat(customAttributeDataType.getDescription()); if (validationExpression != null && !ALL_REGEX.equals(validationExpression.pattern())) { if (customAttributeDataType.getDescription().equalsIgnoreCase(DATE)) { if (!attributeValue.matches(DATE_REGEX)) { reportError(errorKey, RiceKeyConstants.ERROR_INVALID_FORMAT, customAttribute.getLabel(), attributeValue, validFormat); isValid = false; } } else if (!validationExpression.matcher(attributeValue).matches()) { reportError(errorKey, KeyConstants.ERROR_INVALID_FORMAT_WITH_FORMAT, customAttribute.getLabel(), attributeValue, validFormat); isValid = false; } } if (isValid && customAttributeDataType.getDescription().equals("Date")) { if (!StringUtils.isEmpty(attributeValue)) { try { DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT); dateFormat.setLenient(false); dateFormat.parse(attributeValue); } catch (ParseException e) { reportError(errorKey, KeyConstants.ERROR_DATE, attributeValue, customAttribute.getLabel()); isValid = false; } } } // validate BO data against the database contents String lookupClass = customAttribute.getLookupClass(); if (lookupClass != null && lookupClass.equals("org.kuali.kra.bo.KcPerson")) { if (customAttribute.getDataTypeCode().equals("1") && customAttribute.getLookupReturn().equals("userName")) { validFormat = getValidFormat(customAttributeDataType.getDescription()); KcPersonService kps = getKcPersonService(); KcPerson customPerson = kps.getKcPersonByUserName(customAttribute.getValue()); if (customPerson == null) { GlobalVariables.getErrorMap().putError(errorKey, RiceKeyConstants.ERROR_EXISTENCE, customAttribute.getLabel(), attributeValue, validFormat); return false; } else { return true; } } else { // can only validate for userName, if fullName, etc is used then a lookup // is assumed that a lookup is being used, in which case validation // is not necessary return true; } } else if (lookupClass != null && lookupClass.equals("org.kuali.kra.bo.ArgValueLookup")) { ArgValueLookupValuesFinder finder = new ArgValueLookupValuesFinder(); finder.setArgName(customAttribute.getLookupReturn()); List<KeyLabelPair> kv = finder.getKeyValues(); Iterator<KeyLabelPair> i = kv.iterator(); while (i.hasNext()) { KeyLabelPair element = (KeyLabelPair) i.next(); String label = element.getLabel().toLowerCase(); if (label.equals(attributeValue.toLowerCase())) { return true; } } validFormat = getValidFormat(customAttributeDataType.getDescription()); GlobalVariables.getErrorMap().putError(errorKey, RiceKeyConstants.ERROR_EXISTENCE, customAttribute.getLabel(), attributeValue, validFormat); return false; } else if (lookupClass != null) { Class boClass = null; try { boClass = Class.forName(lookupClass); } catch (ClassNotFoundException cnfE) { /* Do nothing, checked on input */ } if (isInvalid(boClass, keyValue(customAttribute.getLookupReturn(), customAttribute.getValue()))) { validFormat = getValidFormat(customAttributeDataType.getDescription()); GlobalVariables.getErrorMap().putError(errorKey, RiceKeyConstants.ERROR_EXISTENCE, customAttribute.getLabel(), attributeValue, validFormat); return false; } } return isValid; }
From source file:org.toobsframework.transformpipeline.xslExtentions.DateHelper.java
private static DateFormat createTimeFormatter(String languageCode) { DateFormat formatter = null;// w w w . j a v a 2s .co m if ((languageCode != null) && !("".equalsIgnoreCase(languageCode.trim()))) { languageCode = languageCode.trim(); Locale locale = new Locale(languageCode.substring(2, 4).toLowerCase(), languageCode.substring(0, 2)); formatter = DateFormat.getTimeInstance(DateFormat.SHORT, locale); } else { formatter = DateFormat.getTimeInstance(DateFormat.SHORT); } return formatter; }
From source file:org.goobi.production.flow.statistics.StatisticsManager.java
/** * Calculate statistics and retrieve List off {@link DataRow} from * {@link StatisticsMode} for presentation and rendering. * *//*from w w w . j a va 2 s . co m*/ public void calculate() { /* * if to-date is before from-date, show error message */ if (sourceDateFrom != null && sourceDateTo != null && sourceDateFrom.after(sourceDateTo)) { Helper.setMeldung("myStatisticButton", "selectedDatesNotValide", "selectedDatesNotValide"); return; } /* * some debugging here */ if (logger.isDebugEnabled()) { logger.debug(sourceDateFrom + " - " + sourceDateTo + " - " + sourceNumberOfTimeUnits + " - " + sourceTimeUnit + "\n" + targetTimeUnit + " - " + targetCalculationUnit + " - " + targetResultOutput + " - " + showAverage); } /* * calculate the statistical results and save it as List of DataTables (because * some statistical questions allow multiple tables and charts) */ IStatisticalQuestion question = statisticMode.getStatisticalQuestion(); try { setTimeFrameToStatisticalQuestion(question); // picking up users input regarding loop Options if (isRenderLoopOption()) { try { ((StatQuestThroughput) question).setIncludeLoops(includeLoops); } catch (Exception e) { // just in case -> shouldn't happen logger.debug("unexpected Exception, wrong class loaded", e); } } if (targetTimeUnit != null) { question.setTimeUnit(targetTimeUnit); } if (targetCalculationUnit != null) { question.setCalculationUnit(targetCalculationUnit); } renderingElements = new ArrayList<>(); List<DataTable> myDataTables = question.getDataTables(dataSource); /* * if DataTables exist analyze them */ if (myDataTables != null) { /* * localize time frame for gui */ StringBuilder subname = new StringBuilder(); if (calculatedStartDate != null) { subname.append( DateFormat.getDateInstance(DateFormat.SHORT, myLocale).format(calculatedStartDate)); } subname.append(" - "); if (calculatedEndDate != null) { subname.append( DateFormat.getDateInstance(DateFormat.SHORT, myLocale).format(calculatedEndDate)); } if (calculatedStartDate == null && calculatedEndDate == null) { subname = new StringBuilder(); } /* * run through all DataTables */ for (DataTable dt : myDataTables) { dt.setSubname(subname.toString()); StatisticsRenderingElement sre = new StatisticsRenderingElement(dt, question); sre.createRenderer(showAverage); renderingElements.add(sre); } } } catch (UnsupportedOperationException e) { Helper.setFehlerMeldung("StatisticButton", "errorOccuredWhileCalculatingStatistics", e); } }
From source file:org.jivesoftware.util.JiveGlobals.java
/** * Formats a Date object to return a time using the global locale. * * @param date the Date to format.//w ww . j a v a 2 s .c o m * @return a String representing the time. */ public static String formatTime(Date date) { if (timeFormat == null) { if (properties != null) { timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, getLocale()); timeFormat.setTimeZone(getTimeZone()); } else { DateFormat instance = DateFormat.getTimeInstance(DateFormat.SHORT, getLocale()); instance.setTimeZone(getTimeZone()); return instance.format(date); } } return timeFormat.format(date); }
From source file:se.streamsource.streamflow.web.application.pdf.CasePdfGenerator.java
public void outputCase(CaseDescriptor cazeDescriptor) throws Throwable { Case caze = cazeDescriptor.getCase(); caseId = ((CaseId.Data) caze).caseId().get(); printedOn = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format(new Date()); document.print("", valueFont).changeColor(headingColor) .println(bundle.getString("caseSummary") + " - " + caseId, h1Font).line(headingColor) .changeColor(Color.BLACK).print("", valueFont); float tabStop = document.calculateTabStop(valueFontBold, bundle.getString("title"), bundle.getString("createdOn"), bundle.getString("createdBy"), bundle.getString("owner"), bundle.getString("assignedTo"), bundle.getString("caseType"), bundle.getString("labels"), bundle.getString("resolution"), bundle.getString("dueOn"), bundle.getString("priority")); if (StringUtils.isNotEmpty(caze.getDescription())) { document.printLabelAndTextWithTabStop(bundle.getString("title") + ": ", valueFontBold, caze.getDescription(), valueFont, tabStop); }//from w w w . j a v a 2 s . c om if (((CasePriority.Data) caze).casepriority().get() != null) { document.printLabelAndTextWithTabStop(bundle.getString("priority") + ": ", valueFontBold, ((CasePriority.Data) caze).casepriority().get().getDescription(), valueFont, tabStop); } if (caze.createdOn().get() != null) { document.printLabelAndTextWithTabStop(bundle.getString("createdOn") + ": ", valueFontBold, DateFormat .getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format(caze.createdOn().get()), valueFont, tabStop); } if (((DueOn.Data) caze).dueOn().get() != null) { document.printLabelAndTextWithTabStop(bundle.getString("dueOn") + ": ", valueFontBold, new SimpleDateFormat(bundle.getString("date_format")).format(((DueOn.Data) caze).dueOn().get()), valueFont, tabStop); } Creator creator = caze.createdBy().get(); if (creator != null) { document.printLabelAndTextWithTabStop(bundle.getString("createdBy") + ": ", valueFontBold, ((Describable) creator).getDescription(), valueFont, tabStop); } Owner owner = ((Ownable.Data) caze).owner().get(); if (owner != null) { document.printLabelAndTextWithTabStop(bundle.getString("owner") + ": ", valueFontBold, ((Describable) owner).getDescription(), valueFont, tabStop); } Assignee assignee = ((Assignable.Data) caze).assignedTo().get(); if (assignee != null) { document.printLabelAndTextWithTabStop(bundle.getString("assignedTo") + ": ", valueFontBold, ((Describable) assignee).getDescription(), valueFont, tabStop); } CaseType caseType = ((TypedCase.Data) caze).caseType().get(); if (caseType != null) { document.printLabelAndTextWithTabStop(bundle.getString("caseType") + ": ", valueFontBold, ((Describable) caseType).getDescription(), valueFont, tabStop); } Resolution resolution = ((Resolvable.Data) caze).resolution().get(); if (resolution != null) { document.printLabelAndTextWithTabStop(bundle.getString("resolution") + ":", valueFontBold, ((Describable) resolution).getDescription(), valueFont, tabStop); } List<Label> labels = ((Labelable.Data) caze).labels().toList(); if (!labels.isEmpty()) { String allLabels = ""; int count = 0; for (Label label : labels) { count++; allLabels += label.getDescription() + (count == labels.size() ? "" : ", "); } document.printLabelAndTextWithTabStop(bundle.getString("labels") + ": ", valueFontBold, allLabels, valueFont, tabStop); } String note = ((Notes) caze).getLastNote() != null ? ((Notes) caze).getLastNote().note().get() : ""; if (!empty(note)) { if (Translator.HTML.equalsIgnoreCase(((Notes) caze).getLastNote().contentType().get())) { note = Translator.htmlToText(note); } document.moveUpOneRow(valueFontBold).print(bundle.getString("note") + ":", valueFontBold) .print(note, valueFont).print("", valueFont); } // traverse structure if (config.contacts().get()) { generateContacts(cazeDescriptor.contacts()); } if (config.submittedForms().get()) { generateSubmittedForms(cazeDescriptor.submittedForms()); } if (config.conversations().get()) { generateConversations(cazeDescriptor.conversations()); } if (config.attachments().get()) { generateAttachments(cazeDescriptor.attachments()); } if (config.caselog().get()) { generateCaselog(cazeDescriptor.caselog()); } }
From source file:org.svij.taskwarriorapp.TaskAddActivity.java
public void onCreate(Bundle savedInstanceState) { setTheme(R.style.Theme_Sherlock_Light_DarkActionBar); super.onCreate(savedInstanceState); setContentView(R.layout.activity_task_add); getSupportActionBar().setDisplayHomeAsUpEnabled(true); final TextView tvDueDate = (TextView) findViewById(R.id.tvDueDate); tvDueDate.setOnClickListener(new View.OnClickListener() { @Override// w ww .j a va2s.c o m public void onClick(View v) { DatePickerFragment date = new DatePickerFragment(); date.setCallBack(onDate); date.setTimestamp(timestamp); date.show(getSupportFragmentManager().beginTransaction(), "date_dialog"); } }); final TextView tvDueTime = (TextView) findViewById(R.id.tvDueTime); tvDueTime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TimePickerFragment date = new TimePickerFragment(); date.setCallBack(onTime); date.setTimestamp(timestamp); date.show(getSupportFragmentManager().beginTransaction(), "time_dialog"); } }); tvDueDate.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (TextUtils.isEmpty(tvDueTime.getText().toString())) { timestamp = 0; } else { cal.set(Calendar.YEAR, Calendar.getInstance().get(Calendar.YEAR)); cal.set(Calendar.MONTH, Calendar.getInstance().get(Calendar.MONTH)); cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance().get(Calendar.DAY_OF_MONTH)); timestamp = cal.getTimeInMillis(); } tvDueDate.setText(""); return true; } }); tvDueTime.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (TextUtils.isEmpty(tvDueDate.getText().toString())) { timestamp = 0; } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); timestamp = cal.getTimeInMillis(); } tvDueTime.setText(""); return true; } }); TaskDataSource dataSource = new TaskDataSource(this); ArrayList<String> projectsAR = dataSource.getProjects(); projectsAR.removeAll(Collections.singleton(null)); String[] projects = projectsAR.toArray(new String[projectsAR.size()]); final AutoCompleteTextView actvProject = (AutoCompleteTextView) findViewById(R.id.actvProject); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, projects); actvProject.setAdapter(adapter); actvProject.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { actvProject.showDropDown(); return false; } }); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { taskID = extras.getString("taskID"); if (taskID != null) { datasource = new TaskDataSource(this); Task task = datasource.getTask(UUID.fromString(taskID)); TextView etTaskAdd = (TextView) findViewById(R.id.etTaskAdd); Spinner spPriority = (Spinner) findViewById(R.id.spPriority); TextView etTags = (TextView) findViewById(R.id.etTags); etTaskAdd.setText(task.getDescription()); if (task.getDue() != null && task.getDue().getTime() != 0) { tvDueDate.setText(DateFormat.getDateInstance(DateFormat.SHORT).format(task.getDue())); if (!DateFormat.getTimeInstance().format(task.getDue()).equals("00:00:00")) { tvDueTime.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(task.getDue())); } cal.setTime(task.getDue()); timestamp = cal.getTimeInMillis(); } actvProject.setText(task.getProject()); Log.i("PriorityID", ":" + task.getPriorityID()); spPriority.setSelection(task.getPriorityID()); etTags.setText(task.getTags()); } else { String action = intent.getAction(); if ((action.equalsIgnoreCase(Intent.ACTION_SEND) || action.equalsIgnoreCase("com.google.android.gm.action.AUTO_SEND")) && intent.hasExtra(Intent.EXTRA_TEXT)) { String s = intent.getStringExtra(Intent.EXTRA_TEXT); TextView etTaskAdd = (TextView) findViewById(R.id.etTaskAdd); etTaskAdd.setText(s); addingTaskFromOtherApp = true; } } } }