List of usage examples for java.text DateFormat MEDIUM
int MEDIUM
To view the source code for java.text DateFormat MEDIUM.
Click Source Link
From source file:at.alladin.rmbt.android.loopmode.LoopModeTestFragment.java
public void updateUi() { if (holder != null && loopService != null) { LoopModeResults loopModeResults = loopService.getLoopModeResults(); holder.counterText.setText(holder.strings.loopModeString + ": " + loopModeResults.getNumberOfTests() + "/" + loopModeResults.getMaxTests() + (Status.RUNNING.equals(loopModeResults.getStatus()) ? "" : " (" + (loopService.isActive() ? holder.strings.waiting : holder.strings.finished) + ")")); if (Status.RUNNING.equals(loopModeResults.getStatus())) { loopModeResults = loopService.updateLoopModeResults(true); if (holder.lastTestText.getVisibility() == View.VISIBLE) { //loop mode just switched from idle/waiting state to test mode holder.lastTestText.setVisibility(View.GONE); holder.unimportantListAdapter = null; }//from w w w . ja v a2 s .c om if (holder.progressBar.getVisibility() == View.GONE) { holder.progressBar.setVisibility(View.VISIBLE); holder.progressText.setVisibility(View.VISIBLE); } } else { if (holder.lastTestText.getVisibility() != View.VISIBLE) { //loop mode just switched from test mode to idle/waiting state holder.unimportantListAdapter = null; holder.lastTestText.setVisibility(View.VISIBLE); } if (holder.progressBar.getVisibility() == View.VISIBLE) { holder.progressBar.setVisibility(View.GONE); holder.progressText.setVisibility(View.GONE); } } //update or initialize the "not so important list" (reason why it's at the bottom of the view) if (holder.unimportantListAdapter != null) { holder.unimportantListAdapter.notifyDataSetChanged(); } else { //different "not so important lists", depending on current test status (running/idle) if (Status.RUNNING.equals(loopModeResults.getStatus())) { //during test mode, show current test server and client's ip final List<DetailsListItem> list = new ArrayList<DetailsListItem>(); list.add(new ServerNameItem(getActivity(), loopModeResults)); list.add(new IpAddressItem(getActivity(), loopModeResults)); holder.unimportantListAdapter = new DetailsInfoListAdapter(getActivity(), list); holder.unimportantInfoList.setAdapter(holder.unimportantListAdapter); } else { //during idle mode, show current data usage, and both loop mode trigger statuses final List<DetailsListItem> list = new ArrayList<DetailsListItem>(); list.add(new TrafficUsageItem(getActivity(), loopModeResults)); list.add(new LoopModeTriggerItem(getActivity(), loopModeResults, TriggerType.MOVEMENT)); list.add(new LoopModeTriggerItem(getActivity(), loopModeResults, TriggerType.TIME)); holder.unimportantListAdapter = new DetailsInfoListAdapter(getActivity(), list); holder.unimportantInfoList.setAdapter(holder.unimportantListAdapter); } } //update last test status if (holder.lastTestText != null && holder.lastTestText.getVisibility() == View.VISIBLE) { String lastTestResult = ""; if (loopModeResults != null && loopModeResults.getLastTestResults() != null) { final Date d = new Date(loopModeResults.getLastTestResults().getLocalStartTimeStamp()); final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault()); switch (loopModeResults.getLastTestResults().getStatus()) { case OK: lastTestResult = getString(R.string.loop_test_last_status_ok); break; case REJECTED: lastTestResult = getString(R.string.loop_test_last_status_rejected); break; default: lastTestResult = getString(R.string.loop_test_last_status_error); } lastTestResult += " (" + df.format(d) + ")"; } holder.lastTestText.setText(lastTestResult); } //update measurement list (up/down/ping/qos: last/current test + median values) if (holder.measurementFragment != null) { if (!holder.measurementFragment.hasResults()) { holder.measurementFragment.initList(loopService.getLoopModeResults()); } else { holder.measurementFragment.updateList(); } } //update info list (location, network, etc...) if (holder.infoFragment != null) { if (!holder.infoFragment.hasResults()) { holder.infoFragment.initList(infoCollector); } else { holder.infoFragment.updateList(); } } //loop service is active (= at least one test still has to be run or finished) if (loopService.isActive()) { int progress = 0; String progressText = ""; int maxProgress = 100; if (rmbtService != null) { if (Status.RUNNING.equals(loopModeResults.getStatus())) { //test currently running, test mode: intermediateResult = rmbtService.getIntermediateResult(intermediateResult); if (intermediateResult != null) { progress = (int) (RMBTTestFragment.calculateProgress(intermediateResult, rmbtService.getQoSTestProgress(), rmbtService.getQoSTestSize()) * 100d); progressText = holder.strings.testRunningString + ": " + progress + "%"; maxProgress = 100; } else if (rmbtService.isConnectionError()) { } else { } } else { //no test running, waiting mode: progress = loopModeResults.getNumberOfTests(); progressText = holder.strings.loopModeString + ": " + loopModeResults.getNumberOfTests() + "/" + loopModeResults.getMaxTests(); maxProgress = loopModeResults.getMaxTests(); } holder.progressBar.setMax(maxProgress); holder.progressBar.setProgress(progress); holder.progressText.setText(progressText); } else { //connecting? } } else { holder.cancelButton.setText(R.string.loop_test_quit); } } else if (holder != null) { //service (still) not bound... } }
From source file:org.dbgl.gui.LogDialog.java
private void repopulateEntries(final Table table, final TableColumn sortColumn, final int sortDirection) { int selLogEntryId = table.getSelectionIndex() == -1 ? -1 : logEntries.get(table.getSelectionIndex()).getId(); try {/* w w w .j ava 2s . c o m*/ String whereClause = filterClauses.isEmpty() ? StringUtils.EMPTY : " WHERE " + StringUtils.join(filterClauses.keySet(), " AND "); logEntries = Database.getInstance().readLogEntries(whereClause, orderByClause); } catch (SQLException e) { GeneralPurposeDialogs.warningMessage(shell, e); logEntries = new ArrayList<LogEntry>(); } table.removeAll(); table.setSortColumn(sortColumn); table.setSortDirection(sortDirection); table.setItemCount(logEntries.size()); int idx = logEntries.size() - 1; for (int i = 0; i < logEntries.size(); i++) { LogEntry entry = logEntries.get(i); TableItem item = table.getItem(i); item.setText(0, Settings.toString(entry.getTime(), DateFormat.MEDIUM)); item.setText(1, getEventName(entry.getEvent())); item.setText(2, getEntityTypeName(entry.getEntityType())); item.setText(3, entry.getEntityTitle()); item.setText(4, String.valueOf(entry.getEntityId())); if (selLogEntryId == logEntries.get(i).getId()) idx = i; } table.setSelection(idx); table.showSelection(); }
From source file:br.msf.commons.util.AbstractDateUtils.java
public static String formatDateTime(final Object date, final Locale locale) { final DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, LocaleUtils.getNullSafeLocale(locale)); return df.format(castToDate(date)); }
From source file:com.sludev.commons.vfs.simpleshell.SimpleShell.java
/** * Does an 'ls' command./*from w w w . j a va2 s . c o m*/ * * @param cmd * @throws org.apache.commons.vfs2.FileSystemException */ public void ls(final String[] cmd) throws FileSystemException { int pos = 1; final boolean recursive; if (cmd.length > pos && cmd[pos].equals("-R")) { recursive = true; pos++; } else { recursive = false; } final FileObject file; if (cmd.length > pos) { file = mgr.resolveFile(cwd, cmd[pos]); } else { file = cwd; } switch (file.getType()) { case FOLDER: // List the contents System.out.println("Contents of " + file.getName()); listChildren(file, recursive, ""); break; case FILE: // Stat the file System.out.println(file.getName()); final FileContent content = file.getContent(); System.out.println("Size: " + content.getSize() + " bytes."); final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); final String lastMod = dateFormat.format(new Date(content.getLastModifiedTime())); System.out.println("Last modified: " + lastMod); break; case IMAGINARY: System.out.println(String.format("File '%s' is IMAGINARY", file.getName())); break; default: log.error(String.format("Unkown type '%d' on '%s'", file.getType(), file.getName())); break; } }
From source file:mobisocial.bento.anyshare.util.DBHelper.java
public long storePicobjInDatabase(DbObj obj, Context context) { long localId = -1; // if replace entry, set ID long hash = obj.getHash(); byte[] raw = obj.getRaw(); String feedname = obj.getFeedName(); long parentid = 0; try {//from w w w .j a v a 2 s .c o m if (obj.getJson().has("target_relation") && obj.getJson().getString("target_relation").equals("parent") && obj.getJson().has("target_hash")) { parentid = objIdForHash(obj.getJson().getLong("target_hash")); } } catch (JSONException e) { e.printStackTrace(); } DbUser usr = obj.getSender(); String sender = ""; if (usr != null) { sender = usr.getName(); } long timestamp = 0; String title = "Picture"; try { timestamp = Long.parseLong(obj.getJson().getString("timestamp")); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } // add object long objId = (localId == -1) ? getNextId() : localId; String desc = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT) .format(new Date(timestamp)); if (!sender.isEmpty()) { desc += " by " + sender; } ContentValues cv = new ContentValues(); cv.put(ItemObject._ID, objId); cv.put(ItemObject.FEEDNAME, feedname); cv.put(ItemObject.TITLE, title); cv.put(ItemObject.DESC, desc); cv.put(ItemObject.TIMESTAMP, timestamp); cv.put(ItemObject.OBJHASH, hash); cv.put(ItemObject.PARENT_ID, parentid); if (raw != null) { cv.put(ItemObject.RAW, raw); } long newObjId = getWritableDatabase().insertOrThrow(ItemObject.TABLE, null, cv); return objId; }
From source file:org.cesecore.certificates.endentity.ExtendedInformation.java
/** Implementation of UpgradableDataHashMap function upgrade. */ public void upgrade() { if (Float.compare(LATEST_VERSION, getVersion()) != 0) { // New version of the class, upgrade String msg = intres.getLocalizedMessage("endentity.extendedinfoupgrade", new Float(getVersion())); log.info(msg);// w ww.j a v a 2 s . com if (data.get(SUBJECTDIRATTRIBUTES) == null) { data.put(SUBJECTDIRATTRIBUTES, ""); } if (data.get(MAXFAILEDLOGINATTEMPTS) == null) { setMaxLoginAttempts(DEFAULT_MAXLOGINATTEMPTS); } if (data.get(REMAININGLOGINATTEMPTS) == null) { setRemainingLoginAttempts(DEFAULT_REMAININGLOGINATTEMPTS); } // In EJBCA 4.0.0 we changed the date format if (getVersion() < 3) { final DateFormat oldDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.US); final FastDateFormat newDateFormat = FastDateFormat.getInstance("yyyy-MM-dd HH:mm"); try { final String oldCustomStartTime = getCustomData(ExtendedInformation.CUSTOM_STARTTIME); if (!isEmptyOrRelative(oldCustomStartTime)) { // We use an absolute time format, so we need to upgrade final String newCustomStartTime = newDateFormat .format(oldDateFormat.parse(oldCustomStartTime)); setCustomData(ExtendedInformation.CUSTOM_STARTTIME, newCustomStartTime); if (log.isDebugEnabled()) { log.debug("Upgraded " + ExtendedInformation.CUSTOM_STARTTIME + " from \"" + oldCustomStartTime + "\" to \"" + newCustomStartTime + "\" in ExtendedInformation."); } } } catch (ParseException e) { log.error("Unable to upgrade " + ExtendedInformation.CUSTOM_STARTTIME + " in extended user information.", e); } try { final String oldCustomEndTime = getCustomData(ExtendedInformation.CUSTOM_ENDTIME); if (!isEmptyOrRelative(oldCustomEndTime)) { // We use an absolute time format, so we need to upgrade final String newCustomEndTime = newDateFormat.format(oldDateFormat.parse(oldCustomEndTime)); setCustomData(ExtendedInformation.CUSTOM_ENDTIME, newCustomEndTime); if (log.isDebugEnabled()) { log.debug( "Upgraded " + ExtendedInformation.CUSTOM_ENDTIME + " from \"" + oldCustomEndTime + "\" to \"" + newCustomEndTime + "\" in ExtendedInformation."); } } } catch (ParseException e) { log.error("Unable to upgrade " + ExtendedInformation.CUSTOM_ENDTIME + " in extended user information.", e); } } // In 4.0.2 we further specify the storage format by saying that UTC TimeZone is implied instead of local server time if (getVersion() < 4) { final String[] timePatterns = { "yyyy-MM-dd HH:mm" }; final String oldStartTime = getCustomData(ExtendedInformation.CUSTOM_STARTTIME); if (!isEmptyOrRelative(oldStartTime)) { try { final String newStartTime = ValidityDate .formatAsUTC(DateUtils.parseDateStrictly(oldStartTime, timePatterns)); setCustomData(ExtendedInformation.CUSTOM_STARTTIME, newStartTime); if (log.isDebugEnabled()) { log.debug("Upgraded " + ExtendedInformation.CUSTOM_STARTTIME + " from \"" + oldStartTime + "\" to \"" + newStartTime + "\" in EndEntityProfile."); } } catch (ParseException e) { log.error("Unable to upgrade " + ExtendedInformation.CUSTOM_STARTTIME + " to UTC in EndEntityProfile! Manual interaction is required (edit and verify).", e); } } final String oldEndTime = getCustomData(ExtendedInformation.CUSTOM_ENDTIME); if (!isEmptyOrRelative(oldEndTime)) { // We use an absolute time format, so we need to upgrade try { final String newEndTime = ValidityDate .formatAsUTC(DateUtils.parseDateStrictly(oldEndTime, timePatterns)); setCustomData(ExtendedInformation.CUSTOM_ENDTIME, newEndTime); if (log.isDebugEnabled()) { log.debug("Upgraded " + ExtendedInformation.CUSTOM_ENDTIME + " from \"" + oldEndTime + "\" to \"" + newEndTime + "\" in EndEntityProfile."); } } catch (ParseException e) { log.error("Unable to upgrade " + ExtendedInformation.CUSTOM_ENDTIME + " to UTC in EndEntityProfile! Manual interaction is required (edit and verify).", e); } } } data.put(VERSION, Float.valueOf(LATEST_VERSION)); } }
From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java
/** * Update the get date field of the window with the value of the movement * object.// ww w . jav a 2s. c o m */ private void updateGetDate() { TextView txt; txt = (TextView) findViewById(R.id.txtGetDate); if (_movement.getGetDate() != null) { txt.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(_movement.getGetDate())); } else { txt.setText(""); } }
From source file:chibi.gemmaanalysis.ExperimentMetaDataExtractorCli.java
public void generateExperimentMetaData(Collection<BioAssaySet> expressionExperiments) throws IOException { File file = getOutputFile(this.viewFile); try (Writer writer = new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)));) { String[] colNames = { "ShortName", "Taxon", "DateUpload", "IsPublic", "NumPlatform", "Platform", "Channel", "IsExonArray", "QtIsRatio", "QtIsNormalized", "QtScale", "NumProfiles", "NumFilteredProfiles", "NumSamples", "NumConditions", "NumReplicatesPerCondition", "PossibleOutliers", "CuratedOutlier", "IsTroubled", "PubTroubled", "PubYear", "PubJournal", "Batch.PC1.Var", "Batch.PC2.Var", "Batch.PC3.Var", "Batch.PC1.Pval", "Batch.PC2.Pval", "Batch.PC3.Pval", "NumFactors", "FactorNames", "FactorCategories", "NumFactorValues" }; // log.info( StringUtils.join( colNames, "\t" ) + "\n" ); writer.write(StringUtils.join(colNames, "\t") + "\n"); int i = 0; Collection<String> failedEEs = new ArrayList<>(); StopWatch timer = new StopWatch(); timer.start();/*from w ww.j a v a2 s. c o m*/ for (BioAssaySet bas : expressionExperiments) { /* * Skip subsets */ if (bas instanceof ExpressionExperimentSubSet) return; try { ExpressionExperiment ee = (ExpressionExperiment) bas; ee = eeService.thawLite(ee); ExpressionExperimentValueObject vo = eeService.loadValueObject(ee.getId()); vo.setIsPublic(!securityService.isPrivate(ee)); log.info("Processing (" + ++i + "/" + expressionExperiments.size() + ") : " + ee); BibliographicReference primaryPublication = ee.getPrimaryPublication(); Status pubStatus = primaryPublication != null ? statusService.getStatus(primaryPublication) : null; Collection<ArrayDesign> arrayDesignsUsed = eeService.getArrayDesignsUsed(ee); Collection<String> arrayDesignIsExon = new ArrayList<>(); Collection<String> arrayDesignTechTypes = new ArrayList<>(); Collection<String> arrayDesignShortNames = new ArrayList<>(); // for multiple platforms e.g. GSE5949 for (ArrayDesign ad : arrayDesignsUsed) { arrayDesignShortNames.add(ad.getShortName()); arrayDesignTechTypes.add(ad.getTechnologyType().getValue()); arrayDesignIsExon.add(ad.getName().toLowerCase().contains("exon") + ""); } QuantitationType qt = null; for (QuantitationType q : ee.getQuantitationTypes()) { if (q.getIsPreferred().booleanValue()) { qt = q; break; } } int manualOutlierCount = 0; for (BioAssay ba : ee.getBioAssays()) { if (ba.getIsOutlier().booleanValue()) { manualOutlierCount++; } } ExperimentalDesign experimentalDesign = edService.load(vo.getExperimentalDesign()); // Batch PCs int maxcomp = 3; BatchEffectDetails batchEffectPC1 = null; BatchEffectDetails batchEffectPC2 = null; BatchEffectDetails batchEffectPC3 = null; Collection<BatchEffectDetails> batchEffects = getBatchEffect(ee, maxcomp); Iterator<BatchEffectDetails> batchEffectsIterator; if (batchEffects == null || batchEffects.size() == 0) { log.warn("No batch effect info"); } else { batchEffectsIterator = batchEffects.iterator(); if (batchEffectsIterator.hasNext()) { batchEffectPC1 = batchEffectsIterator.next(); } if (batchEffectsIterator.hasNext()) { batchEffectPC2 = batchEffectsIterator.next(); } if (batchEffectsIterator.hasNext()) { batchEffectPC3 = batchEffectsIterator.next(); } } // eeService.getExperimentsWithOutliers(); StopWatch timerOutlier = new StopWatch(); timerOutlier.start(); // log.info( "Outlier detection service started " + timer.getTime() + "ms" ); Collection<OutlierDetails> possibleOutliers = outlierDetectionService.identifyOutliers(ee); if (timerOutlier.getTime() > 10000) { log.info("Automatic outlier detection took " + timerOutlier.getTime() + "ms"); } // Collection<OutlierDetails> possibleOutliers = null; // samples per condition boolean removeBatchFactor = false; Collection<String> samplesPerConditionCount = new ArrayList<>(); CountingMap<FactorValueVector> assayCount = ExperimentalDesignUtils.getDesignMatrix(ee, removeBatchFactor); List<FactorValueVector> keys = assayCount.sortedKeyList(true); for (FactorValueVector key : keys) { samplesPerConditionCount.add(Integer.toString(assayCount.get(key).intValue())); } // factor names Collection<ExperimentalFactor> factors = ee.getExperimentalDesign().getExperimentalFactors(); Collection<String> factorNames = new ArrayList<>(); Collection<String> factorCategories = new ArrayList<>(); Collection<Integer> factorValues = new ArrayList<>(); for (ExperimentalFactor f : factors) { factorNames.add(f.getName()); String cat = f.getCategory() != null ? f.getCategory().getCategory() : NA; factorCategories.add(cat); factorValues.add(Integer.valueOf(f.getFactorValues().size())); } int filteredProfilesCount = -1; try { FilterConfig filterConfig = new FilterConfig(); filterConfig.setIgnoreMinimumSampleThreshold(true); filteredProfilesCount = expressionDataMatrixService.getFilteredMatrix(ee, filterConfig, expressionDataMatrixService.getProcessedExpressionDataVectors(ee)).rows(); } catch (Exception e) { log.error(e.getMessage(), e); } String val[] = { vo.getShortName(), vo.getTaxon(), DateFormat.getDateInstance(DateFormat.MEDIUM).format(vo.getDateCreated()), vo != null ? Boolean.toString(vo.getIsPublic()) : NA, Integer.toString(arrayDesignsUsed.size()), StringUtils.join(arrayDesignShortNames, ','), StringUtils.join(arrayDesignTechTypes, ','), // arrayDesign.getTechnologyType().getValue(), // ONE-COLOR, TWO-COLOR, NONE (RNA-seq // GSE37646), DUAL-MODE (one or two color) StringUtils.join(arrayDesignIsExon, ','), // exon GSE28383 qt != null ? Boolean.toString(qt.getIsRatio().booleanValue()) : NA, qt != null ? Boolean.toString(qt.getIsNormalized().booleanValue()) : NA, qt != null ? qt.getScale().getValue() : NA, Integer.toString(vo.getProcessedExpressionVectorCount().intValue()), // NumProfiles Integer.toString(filteredProfilesCount), // NumFilteredProfiles Integer.toString(vo.getBioAssayCount().intValue()), // NumSamples Integer.toString(assayCount.size()), // NumConditions StringUtils.join(samplesPerConditionCount, ","), possibleOutliers != null ? Integer.toString(possibleOutliers.size()) : NA, Integer.toString(manualOutlierCount), Boolean.toString(vo.getTroubled()), pubStatus != null ? Boolean.toString(pubStatus.getTroubled().booleanValue()) : NA, primaryPublication != null ? DateFormat.getDateInstance(DateFormat.MEDIUM) .format(primaryPublication.getPublicationDate()) : NA, primaryPublication != null ? primaryPublication.getPublication() : NA, batchEffectPC1 != null ? Double.toString(batchEffectPC1.getComponentVarianceProportion()) : NA, batchEffectPC2 != null ? Double.toString(batchEffectPC2.getComponentVarianceProportion()) : NA, batchEffectPC3 != null ? Double.toString(batchEffectPC3.getComponentVarianceProportion()) : NA, batchEffectPC1 != null ? Double.toString(batchEffectPC1.getPvalue()) : NA, batchEffectPC2 != null ? Double.toString(batchEffectPC2.getPvalue()) : NA, batchEffectPC3 != null ? Double.toString(batchEffectPC3.getPvalue()) : NA, // factors factors != null ? Integer.toString(factors.size()) : NA, // NumFactors factorNames != null ? StringUtils.join(factorNames, ",") : NA, factorCategories != null ? StringUtils.join(factorCategories, ",") : NA, factorValues != null ? StringUtils.join(factorValues, ",") : NA, }; // log.info( StringUtils.join( val, "\t" ) + "\n" ); writer.write(StringUtils.join(val, "\t") + "\n"); } catch (Exception e) { failedEEs.add(((ExpressionExperiment) bas).getShortName()); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); log.error(sw.toString()); } } log.info("Finished processing " + expressionExperiments.size() + " datasets in " + timer.getTime() + " ms. "); log.info("Writen to " + file); log.info("Number of failed experiment metadata extraction(s): " + failedEEs.size() + " / " + expressionExperiments.size()); if (failedEEs.size() > 0) { log.info("Skipped experiments:"); log.info(StringUtils.join(failedEEs, ",")); } } }
From source file:com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.java
private DateFormat[] getDateFormats(Locale locale) { DateFormat dt1 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, locale); DateFormat dt2 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale); DateFormat dt3 = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale); DateFormat d1 = DateFormat.getDateInstance(DateFormat.SHORT, locale); DateFormat d2 = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); DateFormat d3 = DateFormat.getDateInstance(DateFormat.LONG, locale); DateFormat rfc3399 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); DateFormat[] dfs = { dt1, dt2, dt3, rfc3399, d1, d2, d3 }; //added RFC 3339 date format (XW-473) return dfs;/*from w w w .j a v a 2 s. c om*/ }
From source file:org.sakaiproject.evaluation.tool.utils.RenderingUtils.java
/** * Renders the reports/results column content (since the logic is complex) * /*from w ww. ja v a 2s . c o m*/ * @param container the branch container (must contain the following elements): * evalReportDisplay (output) * evalReportDisplayLink (link) * evalRespondentsDisplayLink (link) * @param eval the evaluation * @param group the eval group * @param viewDate the date at which results can be viewed * @param df the formatter for the dates * @param responsesNeeded responses needed before results can be viewed (0 indicates they can be viewed now), * normally should be the output from EvalBeanUtils.getResponsesNeededToViewForResponseRate(responsesCount, enrollmentsCount) * @param responsesRequired the int value of EvalSettings.RESPONSES_REQUIRED_TO_VIEW_RESULTS * @param evalResultsViewable true if the reports can be viewed based on eval state, prefs, and dates, * usually the result of EvalBeanUtils.checkInstructorViewResultsForEval(), * NOTE: this doesn't guarantee the link is visible as there might not be enough respondents * or the view date may not be reached yet (should handle EvalSettings.INSTRUCTOR_ALLOWED_VIEW_RESULTS) * * Sample rendering html (from summary.html): <tr rsf:id="evalResponsesList:"> ... <td nowrap="nowrap"> <span rsf:id="evalReportDisplay"></span> <a rsf:id="evalReportDisplayLink" href="report_view.html">results</a> <a rsf:id="evalRespondentsDisplayLink" class="left-separator" href="evaluation_responders.html">respondents</a> </td> </tr> * */ public static void renderResultsColumn(UIBranchContainer container, EvalEvaluation eval, EvalGroup group, Date viewDate, DateFormat df, int responsesNeeded, int responsesRequired, boolean evalResultsViewable) { Date now = new Date(); if (container == null) { throw new IllegalArgumentException("container must be set"); } if (eval == null) { throw new IllegalArgumentException("eval must be set"); } String evalState = EvalUtils.getEvaluationState(eval, true); if (viewDate == null) { viewDate = eval.getSafeViewDate(); // ensure no NPE } if (df == null) { df = DateFormat.getDateInstance(DateFormat.MEDIUM); } String viewableDate = df.format(viewDate); /* Reports column logic: * - if eval OPEN (in progress) * -- if view date not reached and if responses count not reached: show "{viewDate}: if at least {num} responses" * -- if responses count not reached: show "After {num} more responses" * -- if view date not reached but responses count reached: show "{viewDate}" * -- if INSTRUCTOR_ALLOWED_VIEW_RESULTS and responses count reached: show link to report view * - if eval CLOSED * -- if responses count not reached: show "After {num} more responses" * -- if view date not reached but responses count reached: show "{viewDate}" * -- if view date and responses count reached: show link to report view */ boolean evalOpen = EvalUtils.checkStateBefore(evalState, EvalConstants.EVALUATION_STATE_CLOSED, false); // eval is open (still in progress) if (evalOpen && !evalResultsViewable && responsesNeeded > 0) { // show view date + responses message (only if the eval is still OPEN) // controlevaluations.eval.report.viewablew.awaiting.responses UIMessage resultOutput = UIMessage.make(container, "evalReportDisplay", "controlevaluations.eval.report.viewable.least.responses", new Object[] { viewableDate, responsesRequired }); // indicate the viewable date as well resultOutput.decorate(new UITooltipDecorator( UIMessage.make("controlevaluations.eval.report.viewable.on", new Object[] { viewableDate }))); } else if (responsesNeeded > 0) { // not viewable yet because there are not enough responses UIMessage resultOutput = UIMessage.make(container, "evalReportDisplay", "controlevaluations.eval.report.after.responses", new Object[] { responsesNeeded }); // indicate the viewable date as well resultOutput.decorate(new UITooltipDecorator( UIMessage.make("controlevaluations.eval.report.viewable.on", new Object[] { viewableDate }))); } else if (now.before(viewDate) || !evalResultsViewable) { // not viewable yet because of the view date UIOutput resultOutput = UIOutput.make(container, "evalReportDisplay", viewableDate); if (responsesNeeded == 0) { // just show date if we have enough responses resultOutput.decorate(new UITooltipDecorator(UIMessage .make("controlevaluations.eval.report.viewable.on", new Object[] { viewableDate }))); } else { // show if responses are still needed resultOutput.decorate(new UITooltipDecorator(UIMessage.make( "controlevaluations.eval.report.awaiting.responses", new Object[] { responsesNeeded }))); } } else { // if (evalResultsViewable) // reports are viewable so just display the reports link ViewParameters viewparams; if (group != null) { viewparams = new ReportParameters(ReportsViewingProducer.VIEW_ID, eval.getId(), new String[] { group.evalGroupId }); } else { viewparams = new ReportParameters(ReportChooseGroupsProducer.VIEW_ID, eval.getId()); } UIInternalLink.make(container, "evalReportDisplayLink", UIMessage.make("controlevaluations.eval.report.link"), viewparams); } }