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:com.cachirulop.moneybox.activity.MovementDetailActivity.java
/** * Update the insert date field of the window with the value of the movement * object.//from w ww. j av a2s . c om */ private void updateInsertDate() { TextView txt; txt = (TextView) findViewById(R.id.txtDate); txt.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(_movement.getInsertDate())); }
From source file:com.idega.block.cal.renderer.AbstractCompactScheduleRenderer.java
/** * <p>/*from w w w. java 2 s . com*/ * Draw the schedule entries in the specified day cell * </p> * * @param context * the FacesContext * @param schedule * the schedule * @param day * the day * @param writer * the ResponseWriter * * @throws IOException * when the entries could not be drawn */ protected void writeEntries(FacesContext context, HtmlSchedule schedule, ScheduleDay day, ResponseWriter writer) throws IOException { //final String clientId = schedule.getClientId(context); //final FormInfo parentFormInfo = RendererUtils.findNestingForm(schedule, context); //final String formId = parentFormInfo == null ? null : parentFormInfo.getFormName(); final TreeSet entrySet = new TreeSet(comparator); for (Iterator entryIterator = day.iterator(); entryIterator.hasNext();) { ScheduleEntry entry = (ScheduleEntry) entryIterator.next(); entrySet.add(entry); } for (Iterator entryIterator = entrySet.iterator(); entryIterator.hasNext();) { ScheduleEntry entry = (ScheduleEntry) entryIterator.next(); writer.startElement(HTML.DIV_ELEM, schedule); writer.startElement(HTML.DIV_ELEM, schedule); if (isSelected(schedule, entry)) { writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule, "selected"), null); } //compose the CSS style for the entry box StringBuffer entryStyle = new StringBuffer(); entryStyle.append("width: 100%;"); String entryColor = getEntryRenderer(schedule).getColor(context, schedule, entry, isSelected(schedule, entry)); if (isSelected(schedule, entry) && entryColor != null) { entryStyle.append(" background-color: "); entryStyle.append(entryColor); entryStyle.append(";"); entryStyle.append(" border-color: "); entryStyle.append(entryColor); entryStyle.append(";"); } writer.writeAttribute(HTML.STYLE_ATTR, entryStyle.toString(), null); // draw the tooltip if (showTooltip(schedule)) { getEntryRenderer(schedule).renderToolTip(context, writer, schedule, entry, isSelected(schedule, entry)); } if (!isSelected(schedule, entry) && !schedule.isReadonly()) { writer.startElement("a", schedule); writer.writeAttribute(HTML.CLASS_ATTR, CalendarConstants.SCHEDULE_ENTRY_STYLE_CLASS, null); writer.writeAttribute(HTML.HREF_ATTR, "javascript:void(0)", null); writer.writeAttribute("entryid", entry.getId(), null); DateFormat format; String pattern = null; if ((pattern != null) && (pattern.length() > 0)) { format = new SimpleDateFormat(pattern); } else { if (context.getApplication().getDefaultLocale() != null) { format = DateFormat.getDateInstance(DateFormat.MEDIUM, context.getApplication().getDefaultLocale()); } else { format = DateFormat.getDateInstance(DateFormat.MEDIUM); } } String startTime = format.format(entry.getStartTime()); startTime += " "; startTime += entry.getStartTime().getHours(); startTime += ":"; if (entry.getStartTime().getMinutes() < 10) { startTime += "0"; startTime += entry.getStartTime().getMinutes(); } else { startTime += entry.getStartTime().getMinutes(); } String endTime = ""; endTime += entry.getEndTime().getHours(); endTime += ":"; if (entry.getEndTime().getMinutes() < 10) { endTime += "0"; endTime += entry.getEndTime().getMinutes(); } else { endTime += entry.getEndTime().getMinutes(); } } // draw the content getEntryRenderer(schedule).renderContent(context, writer, schedule, day, entry, true, isSelected(schedule, entry)); if (!isSelected(schedule, entry) && !schedule.isReadonly()) { writer.endElement("a"); } writer.endElement(HTML.DIV_ELEM); writer.endElement(HTML.DIV_ELEM); } }
From source file:com.mg.framework.utils.MiscUtils.java
/** * ? ? ?? ? <code>DATE, DATETIME, TIME</code> * * @param value //w w w .j av a2 s .com * @param metadata * @param locale * @return ? ? ? ? ? <code>value == null</code> * @throws NullPointerException ? <code>metadata == null</code> */ public static String getDateTextRepresentation(Date value, FieldMetadata metadata, Locale locale) { if (value == null || DateTimeUtils.isBoundDateValue(value)) return StringUtils.EMPTY_STRING; if (metadata == null) return value.toString(); DateFormat df; switch (metadata.getBuiltInType()) { case DATE: df = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); break; case DATETIME: df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale); break; case TIME: df = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); break; default: return value.toString(); } return df.format(value); }
From source file:com.diablominer.DiabloMiner.DiabloMiner.java
public static String dateTime() { return "[" + DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date()) + "]"; }
From source file:org.paxle.parser.html.impl.HtmlParser.java
private static String printDate(long millis) { return DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH).format(new Date(millis)); }
From source file:org.apache.accumulo.monitor.servlets.TServersServlet.java
public static void doDeadServerTable(HttpServletRequest req, StringBuilder sb, Table deadTServerList, List<DeadServer> obit) { if (obit != null && !obit.isEmpty()) { deadTServerList.addSortableColumn("Server"); deadTServerList.addSortableColumn("Last Updated", new DateTimeType(DateFormat.MEDIUM, DateFormat.SHORT), null); deadTServerList.addSortableColumn("Event"); deadTServerList.addUnsortableColumn("Clear"); for (DeadServer dead : obit) deadTServerList.addRow(TServerLinkType.displayName(dead.server), dead.lastStatus, dead.status, "<a href='/op?action=clearDeadServer&redir=" + currentPage(req) + "&server=" + encode(dead.server) + "'>clear</a>"); deadTServerList.generate(req, sb); }//from ww w . j a v a 2 s . c o m }
From source file:org.hoteia.qalingo.core.web.mvc.factory.impl.BackofficeViewBeanFactoryImpl.java
/** * @throws Exception// w w w . j a va 2s. c om * */ public RetailerViewBean buildRetailerViewBean(final RequestData requestData, final Retailer retailer) throws Exception { final Localization localization = requestData.getMarketAreaLocalization(); final Locale locale = localization.getLocale(); final RetailerViewBean retailerViewBean = new RetailerViewBean(); // CLONE THE CURRENT REQUEST DATE TO BUILD THE CHANGE CONTEXT URL (MENU) RequestData requestDataChangecontext = new RequestData(); BeanUtils.copyProperties(requestData, requestDataChangecontext); requestDataChangecontext.setMarketAreaRetailer(retailer); retailerViewBean.setChangeContextUrl(backofficeUrlService.buildChangeContextUrl(requestDataChangecontext)); retailerViewBean.setId(retailer.getId()); retailerViewBean.setVersion(retailer.getVersion()); retailerViewBean.setCode(retailer.getCode()); retailerViewBean.setName(retailer.getName()); retailerViewBean.setDescription(retailer.getDescription()); if (retailer.getAddresses() != null) { RetailerAddress defaultAddress = retailer.getDefaultAddress(); if (defaultAddress != null) { retailerViewBean.getDefaultAddress().setAddress1(defaultAddress.getAddress1()); retailerViewBean.getDefaultAddress().setAddress2(defaultAddress.getAddress2()); retailerViewBean.getDefaultAddress() .setAddressAdditionalInformation(defaultAddress.getAddressAdditionalInformation()); retailerViewBean.getDefaultAddress().setPostalCode(defaultAddress.getPostalCode()); retailerViewBean.getDefaultAddress().setCity(defaultAddress.getCity()); retailerViewBean.getDefaultAddress().setStateCode(defaultAddress.getStateCode()); retailerViewBean.getDefaultAddress().setStateLabel(defaultAddress.getStateCode()); retailerViewBean.getDefaultAddress().setAreaCode(defaultAddress.getAreaCode()); retailerViewBean.getDefaultAddress().setAreaLabel(defaultAddress.getAreaCode()); retailerViewBean.getDefaultAddress().setCountryCode(defaultAddress.getCountryCode()); String countryLabel = referentialDataService.getCountryByLocale(defaultAddress.getCountryCode(), locale); retailerViewBean.getDefaultAddress().setCountryLabel(countryLabel); retailerViewBean.getDefaultAddress().setLongitude(defaultAddress.getLongitude()); retailerViewBean.getDefaultAddress().setLatitude(defaultAddress.getLatitude()); retailerViewBean.getDefaultAddress().setPhone(defaultAddress.getPhone()); retailerViewBean.getDefaultAddress().setMobile(defaultAddress.getMobile()); retailerViewBean.getDefaultAddress().setFax(defaultAddress.getFax()); retailerViewBean.getDefaultAddress().setEmail(defaultAddress.getEmail()); String websiteUrl = defaultAddress.getWebsite(); if (StringUtils.isNotEmpty(websiteUrl) && !websiteUrl.contains("http")) { websiteUrl = "http://" + websiteUrl; } retailerViewBean.getDefaultAddress().setWebsite(websiteUrl); } } DateFormat dateFormat = requestUtil.getFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM); Date createdDate = retailer.getDateCreate(); if (createdDate != null) { retailerViewBean.setCreatedDate(dateFormat.format(createdDate)); } else { retailerViewBean.setCreatedDate(Constants.NOT_AVAILABLE); } Date updatedDate = retailer.getDateUpdate(); if (updatedDate != null) { retailerViewBean.setUpdatedDate(dateFormat.format(updatedDate)); } else { retailerViewBean.setUpdatedDate(Constants.NOT_AVAILABLE); } Map<String, String> urlParams = new HashMap<String, String>(); urlParams.put(RequestConstants.REQUEST_PARAMETER_RETAILER_DETAILS_CODE, retailer.getCode()); String detailsUrl = backofficeUrlService.generateUrl(BoUrls.RETAILER_DETAILS, requestData, urlParams); String editUrl = backofficeUrlService.generateUrl(BoUrls.RETAILER_EDIT, requestData, urlParams); retailerViewBean.setDetailsUrl(detailsUrl); retailerViewBean.setEditUrl(editUrl); return retailerViewBean; }
From source file:desmoj.extensions.grafic.util.Plotter.java
/** * configure domainAxis (label, timeZone, locale, tick labels) * of time-series chart//from w ww .j a va 2 s . co m * @param dateAxis */ private void configureDomainAxis(DateAxis dateAxis) { if (this.begin != null) dateAxis.setMinimumDate(this.begin); if (this.end != null) dateAxis.setMaximumDate(this.end); dateAxis.setTimeZone(this.timeZone); Date dateMin = dateAxis.getMinimumDate(); Date dateMax = dateAxis.getMaximumDate(); //DateFormat formatter = new SimpleDateFormat("d.MM.yyyy HH:mm:ss.SSS");; DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM, locale); String label = "Time: " + formatter.format(dateMin) + " .. " + formatter.format(dateMax); formatter = new SimpleDateFormat("z"); label += " " + formatter.format(dateMax); dateAxis.setLabel(label); TimeInstant max = new TimeInstant(dateMax); TimeInstant min = new TimeInstant(dateMin); TimeSpan diff = TimeOperations.diff(max, min); if (TimeSpan.isLongerOrEqual(diff, new TimeSpan(1, TimeUnit.DAYS))) formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale); else if (TimeSpan.isLongerOrEqual(diff, new TimeSpan(1, TimeUnit.HOURS))) formatter = DateFormat.getTimeInstance(DateFormat.SHORT, locale); else if (TimeSpan.isLongerOrEqual(diff, new TimeSpan(1, TimeUnit.MINUTES))) formatter = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); else formatter = new SimpleDateFormat("HH:mm:ss.SSS"); dateAxis.setDateFormatOverride(formatter); dateAxis.setVerticalTickLabels(true); }
From source file:org.nuxeo.ecm.core.storage.sql.coremodel.SQLSession.java
@Override public Document importDocument(String uuid, Document parent, String name, String typeName, Map<String, Serializable> properties) throws DocumentException { assert Model.PROXY_TYPE == CoreSession.IMPORT_PROXY_TYPE; boolean isProxy = typeName.equals(Model.PROXY_TYPE); Map<String, Serializable> props = new HashMap<String, Serializable>(); Long pos = null; // TODO pos if (!isProxy) { // version & live document props.put(Model.MISC_LIFECYCLE_POLICY_PROP, properties.get(CoreSession.IMPORT_LIFECYCLE_POLICY)); props.put(Model.MISC_LIFECYCLE_STATE_PROP, properties.get(CoreSession.IMPORT_LIFECYCLE_STATE)); // compat with old lock import @SuppressWarnings("deprecation") String key = (String) properties.get(CoreSession.IMPORT_LOCK); if (key != null) { String[] values = key.split(":"); if (values.length == 2) { String owner = values[0]; Calendar created = new GregorianCalendar(); try { created.setTimeInMillis( DateFormat.getDateInstance(DateFormat.MEDIUM).parse(values[1]).getTime()); } catch (ParseException e) { // use current date }/*from ww w.ja v a 2 s . c o m*/ props.put(Model.LOCK_OWNER_PROP, owner); props.put(Model.LOCK_CREATED_PROP, created); } } Serializable importLockOwnerProp = properties.get(CoreSession.IMPORT_LOCK_OWNER); if (importLockOwnerProp != null) { props.put(Model.LOCK_OWNER_PROP, importLockOwnerProp); } Serializable importLockCreatedProp = properties.get(CoreSession.IMPORT_LOCK_CREATED); if (importLockCreatedProp != null) { props.put(Model.LOCK_CREATED_PROP, importLockCreatedProp); } props.put(Model.MAIN_MAJOR_VERSION_PROP, properties.get(CoreSession.IMPORT_VERSION_MAJOR)); props.put(Model.MAIN_MINOR_VERSION_PROP, properties.get(CoreSession.IMPORT_VERSION_MINOR)); props.put(Model.MAIN_IS_VERSION_PROP, properties.get(CoreSession.IMPORT_IS_VERSION)); } Node parentNode; if (parent == null) { // version parentNode = null; props.put(Model.VERSION_VERSIONABLE_PROP, idFromString((String) properties.get(CoreSession.IMPORT_VERSION_VERSIONABLE_ID))); props.put(Model.VERSION_CREATED_PROP, properties.get(CoreSession.IMPORT_VERSION_CREATED)); props.put(Model.VERSION_LABEL_PROP, properties.get(CoreSession.IMPORT_VERSION_LABEL)); props.put(Model.VERSION_DESCRIPTION_PROP, properties.get(CoreSession.IMPORT_VERSION_DESCRIPTION)); props.put(Model.VERSION_IS_LATEST_PROP, properties.get(CoreSession.IMPORT_VERSION_IS_LATEST)); props.put(Model.VERSION_IS_LATEST_MAJOR_PROP, properties.get(CoreSession.IMPORT_VERSION_IS_LATEST_MAJOR)); } else { parentNode = ((SQLDocument) parent).getNode(); if (isProxy) { // proxy props.put(Model.PROXY_TARGET_PROP, idFromString((String) properties.get(CoreSession.IMPORT_PROXY_TARGET_ID))); props.put(Model.PROXY_VERSIONABLE_PROP, idFromString((String) properties.get(CoreSession.IMPORT_PROXY_VERSIONABLE_ID))); } else { // live document props.put(Model.MAIN_BASE_VERSION_PROP, idFromString((String) properties.get(CoreSession.IMPORT_BASE_VERSION_ID))); props.put(Model.MAIN_CHECKED_IN_PROP, properties.get(CoreSession.IMPORT_CHECKED_IN)); } } return importChild(uuid, parentNode, name, pos, typeName, props); }
From source file:net.wastl.webmail.storage.FileStorage.java
protected String formatDate(long date) { if (df == null) { TimeZone tz = TimeZone.getDefault(); df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.DEFAULT, Locale.getDefault()); df.setTimeZone(tz);/*from www .j a v a 2 s . c om*/ } String now = df.format(new Date(date)); return now; }