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:org.apache.hadoop.security.token.DtFileOperations.java
/** Format a long integer type into a date string. */ private static String formatDate(long date) { DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); return df.format(new Date(date)); }
From source file:org.openmrs.web.taglib.ActiveListWidget.java
public int doStartTag() { UserContext userContext = Context.getUserContext(); Locale loc = userContext.getLocale(); DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, loc); Set<Concept> addConceptList = OpenmrsUtil.conceptSetHelper(addConcept); Set<Concept> removeConceptList = OpenmrsUtil.conceptSetHelper(removeConcept); List<Concept> otherConceptList = OpenmrsUtil.conceptListHelper(otherGroupedConcepts); boolean doObsGroups = otherConceptList.size() > 0; if (onDate == null) onDate = new Date(); // maps Concept to the date that became active Map<Concept, Obs> activeList = new HashMap<Concept, Obs>(); for (Obs o : observations) { // skip observations in the future if (OpenmrsUtil.compare(o.getObsDatetime(), onDate) > 0) continue; Concept c = o.getConcept();/*from w w w . jav a 2 s . co m*/ Concept toDo = o.getValueCoded(); if (toDo == null) toDo = c; if (addConceptList.contains(o.getConcept())) { Date newActiveDate = o.getObsDatetime(); Obs tmp = activeList.get(c); Date currentActiveDate = tmp == null ? null : tmp.getObsDatetime(); if (currentActiveDate == null || newActiveDate.compareTo(currentActiveDate) < 0) activeList.put(toDo, o); } else if (removeConceptList.contains(o.getConcept())) { activeList.remove(toDo); } } List<Map.Entry<Concept, Obs>> ordered = new ArrayList<Map.Entry<Concept, Obs>>(activeList.entrySet()); Collections.sort(ordered, new Comparator<Map.Entry<Concept, Obs>>() { public int compare(Map.Entry<Concept, Obs> left, Map.Entry<Concept, Obs> right) { return left.getValue().getObsDatetime().compareTo(right.getValue().getObsDatetime()); } }); Map<Obs, Collection<Obs>> obsGroups = new HashMap<Obs, Collection<Obs>>(); if (doObsGroups) { ObsService os = Context.getObsService(); for (Obs o : activeList.values()) if (o.isObsGrouping()) obsGroups.put(o, o.getGroupMembers()); } StringBuilder sb = new StringBuilder(); String before = ""; String after = ""; String obsGroupHeader = ""; String beforeItem = ""; String afterItem = ""; String obsGroupItemSeparator = ""; if ("ol".equals(displayStyle) || "ul".equals(displayStyle)) { before = "<" + displayStyle + ">"; after = "</" + displayStyle + ">"; beforeItem = "<li>"; afterItem = "</li>"; obsGroupItemSeparator = ", "; } else if (displayStyle.startsWith("separator:")) { afterItem = displayStyle.substring(displayStyle.indexOf(":") + 1); obsGroupItemSeparator = " "; } else if ("table".equals(displayStyle)) { before = "<table>"; after = "</table>"; beforeItem = "<tr><td>"; afterItem = "</td></tr>"; obsGroupItemSeparator = "</td><td>"; if (doObsGroups) { StringBuilder s = new StringBuilder(); s.append("<tr><th></th>"); for (Concept c : otherConceptList) { ConceptName cn = c.getBestShortName(loc); s.append("<th><small>" + cn.getName() + "</small></th>"); } s.append("</tr>"); obsGroupHeader = s.toString(); } } else { throw new RuntimeException("Unknown displayStyle: " + displayStyle); } if (ordered.size() > 0) { sb.append(before); sb.append(obsGroupHeader); for (Map.Entry<Concept, Obs> e : ordered) { sb.append(beforeItem); sb.append(e.getKey().getName(loc, false).getName()); if (showDate) sb.append(" ").append(df.format(e.getValue().getObsDatetime())); if (doObsGroups) { Collection<Obs> obsGroup = obsGroups.get(e.getValue()); for (Concept c : otherConceptList) { sb.append(obsGroupItemSeparator); if (obsGroup != null) { for (Obs o : obsGroup) { if (c.equals(o.getConcept())) { sb.append(o.getValueAsString(loc)); break; } } } } } sb.append(afterItem); } sb.append(after); } try { JspWriter w = pageContext.getOut(); w.println(sb); } catch (IOException ex) { log.error("Error while writing to JSP", ex); } return SKIP_BODY; }
From source file:org.hippoecm.frontend.plugins.cms.dashboard.EventModel.java
public EventModel(JcrNodeModel eventNode) { this(eventNode, null, DateFormat.getDateInstance(DateFormat.SHORT)); }
From source file:org.kalypso.utils.log.FileLog.java
/** * The constructor.// w w w .j a va 2 s.c o m * * @param file * The log file. May not be null. */ public FileLog(final File file) { /* The log file may not be null. */ Assert.isNotNull(file); m_file = file; m_df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); }
From source file:de.odysseus.calyxo.base.util.ParseUtils.java
private static Date parseDate(String value) throws ParseException { DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT, locale); format.setTimeZone(TimeZone.getTimeZone("GMT")); return (Date) parse(format, value); }/*w ww . j ava 2 s .co m*/
From source file:org.rhq.modules.plugins.jbossas7.util.PatchDetails.java
public static List<PatchDetails> fromHistory(String patchHistoryOutcome) { ObjectMapper mapper = new ObjectMapper(); Result result;//from w w w . j ava 2 s . c o m try { result = mapper.readValue(patchHistoryOutcome, Result.class); } catch (IOException e) { LOG.warn("Failed to parse the output of the 'patch history' command with message '" + e.getMessage() + "'. The output was:\n" + patchHistoryOutcome); return Collections.emptyList(); } if (!result.isSuccess()) { if (LOG.isDebugEnabled()) { LOG.debug("'patch history' command didn't succeed: " + result); } return Collections.emptyList(); } // expecting a list of maps of string->string if (!(result.getResult() instanceof List)) { if (LOG.isDebugEnabled()) { LOG.debug("Unexpected patch history results. Expected list but found " + (result.getResult() == null ? "null" : result.getResult().getClass().toString())); } return Collections.emptyList(); } @SuppressWarnings("unchecked") List<Map<String, String>> patches = (List<Map<String, String>>) result.getResult(); if (patches.isEmpty()) { return Collections.emptyList(); } List<PatchDetails> ret = new ArrayList<PatchDetails>(); for (Map<String, String> patchDescr : patches) { String patchId = patchDescr.get("patch-id"); Date appliedAt = null; Type type = Type.fromJsonValue(patchDescr.get("type")); try { //This seems to be the date format AS are using DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); appliedAt = format.parse(patchDescr.get("applied-at")); } catch (ParseException e) { LOG.info("Failed to parse the installation date of the patch " + patchId + ": '" + patchDescr.get("applied-at") + "' with error message: " + e.getMessage()); } ret.add(new PatchDetails(patchId, type, appliedAt)); } return ret; }
From source file:org.sonar.server.charts.jruby.TrendsChart.java
public TrendsChart(int width, int height, String localeKey, boolean displayLegend) { super(width, height); this.displayLegend = displayLegend; seriesById = new TreeMap<Long, TimeSeries>(); plot = new XYPlot(); DateAxis dateAxis = new DateAxis(); dateAxis.setDateFormatOverride(/* w ww. j av a2 s.c o m*/ DateFormat.getDateInstance(DateFormat.SHORT, LocaleUtils.toLocale(localeKey))); plot.setDomainAxis(dateAxis); }
From source file:org.libreplan.web.orders.DynamicDatebox.java
public DynamicDatebox(Getter<Date> getter, Setter<Date> setter) { this.setter = setter; this.getter = getter; this.dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locales.getCurrent()); }
From source file:threads.HeapStat.java
/** * Creates a new instance of HeapStat//from w w w . ja v a 2 s.c o m */ public HeapStat(JProgressBar jpHeap, JProgressBar jpTimeout, JLabel clock, Closure timeoutAction) { super(); this.jpTimeout = jpTimeout; this.timeoutAction = timeoutAction; uhrzeit = DateFormat.getTimeInstance(DateFormat.SHORT); datum = DateFormat.getDateInstance(DateFormat.LONG); touch(); this.clock = clock; this.setName("HeapStat"); this.interrupted = false; this.jpHeap = jpHeap; this.jpHeap.setStringPainted(true); }
From source file:com.sonicle.webtop.core.util.AppLocale.java
public AppLocale(String languageTag) { this.id = LangUtils.homogenizeLocaleId(languageTag); Locale locale = LangUtils.languageTagToLocale(languageTag); shortDatePattern = getDateFormatter(DateFormat.SHORT, locale).toPattern(); longDatePattern = getDateFormatter(DateFormat.LONG, locale).toPattern(); shortTimePattern = getTimeFormatter(DateFormat.SHORT, locale).toPattern(); longTimePattern = getTimeFormatter(DateFormat.LONG, locale).toPattern(); }