List of usage examples for java.text DateFormat getDateTimeInstance
public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle)
From source file:com.facultyshowcase.app.ui.UIUtil.java
public static void writeProperty(EntityUtilWriter writer, String htmlClass, String label, Date date) { final DateFormat parser = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); writeContainerBeginning(writer, htmlClass); writeLabel(writer, htmlClass, label); writer.append("<span "); writer.appendEscapedAttribute(CLASS, CmsHTMLClassNames.convertClassName(PROP + " " + htmlClass)); writer.append(">"); writer.appendEscapedData(date != null ? parser.format(date) : StringUtils.EMPTY); writer.append("</span>"); writeContainerEnd(writer);// ww w .j av a 2s . co m }
From source file:org.apache.fop.tools.anttasks.FileCompare.java
private void writeHeader(PrintWriter results) { String dateTime = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date()); results.println("<html><head><title>Test Results</title></head><body>\n"); results.println("<h2>Compare Results<br>"); results.println("<font size='1'>created " + dateTime + "</font></h2>"); results.println("<table cellpadding='10' border='2'><thead>" + "<th align='center'>reference file</th>" + "<th align='center'>test file</th>" + "<th align='center'>identical?</th></thead>"); }
From source file:com.bdb.weather.display.stripchart.StripChart.java
private void createRenderer(int dataset, TimeSeriesCollection collection, NumberFormat format) { DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); renderer.setBaseShapesVisible(false); renderer.setBaseToolTipGenerator(/*from ww w . j ava2s.com*/ new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG), format)); renderer.setDefaultEntityRadius(1); plot.setRenderer(dataset, renderer); plot.setDataset(dataset, collection); }
From source file:org.opencms.scheduler.jobs.CmsPublishJob.java
/** * @see org.opencms.scheduler.I_CmsScheduledJob#launch(org.opencms.file.CmsObject, java.util.Map) *///from www. j a v a 2 s .c o m public synchronized String launch(CmsObject cms, Map<String, String> parameters) throws Exception { Date jobStart = new Date(); String finishMessage; String unlock = parameters.get(PARAM_UNLOCK); String linkcheck = parameters.get(PARAM_LINKCHECK); CmsProject project = cms.getRequestContext().getCurrentProject(); CmsLogReport report = new CmsLogReport(cms.getRequestContext().getLocale(), CmsPublishJob.class); try { // check if the unlock parameter was given if (Boolean.valueOf(unlock).booleanValue()) { cms.unlockProject(project.getUuid()); } // validate links if linkcheck parameter was given if (Boolean.valueOf(linkcheck).booleanValue()) { OpenCms.getPublishManager().validateRelations(cms, OpenCms.getPublishManager().getPublishList(cms), report); } // 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(300000); beforeLastTime = lastTime; lastTime = report.getLastEntryTime(); } // send publish notification if (report.hasWarning() || report.hasError()) { try { String userName = 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:de.uni_koeln.spinfo.maalr.webapp.controller.AdminController.java
@RequestMapping("/admin/export") public void export(@RequestParam(value = "all", defaultValue = "true") boolean allVersions, @RequestParam(value = "dropKeys", defaultValue = "false") boolean dropKeys, HttpServletResponse response)/* w w w.j a v a2 s . c o m*/ throws IOException, NoDatabaseAvailableException, JAXBException, NoSuchAlgorithmException { response.setContentType("application/zip"); StringBuilder fileName = new StringBuilder(); fileName.append("maalr_db_dump_"); if (allVersions) { fileName.append("all_versions_"); } else { fileName.append("current_versions_"); } if (dropKeys) { fileName.append("anonymized_"); } fileName.append(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date())); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".zip"); ServletOutputStream out = response.getOutputStream(); service.exportData(allVersions, dropKeys, out, fileName.toString()); }
From source file:omero.gateway.model.PlateAcquisitionData.java
/** * Returns the label associated to the plate acquisition. * * @return See above.//from w w w .jav a 2 s .c om */ public String getLabel() { String name = getName(); if (StringUtils.isNotBlank(name)) { return name; } Timestamp time = getStartTime(); String start = ""; String end = ""; if (time != null) { start = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(time); } String[] values = start.split(" "); String date = ""; String dateEnd = ""; if (values.length > 1) { date = values[0]; start = start.substring(date.length() + 1); } time = getEndTime(); if (time != null) { end = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(time); } values = end.split(" "); if (values.length > 1) { if (!date.equals(values[0])) dateEnd = values[0]; end = end.substring(values[0].length() + 1); } String value = ""; if (start.length() == 0 && end.length() == 0) return DEFAULT_TEXT + getId(); if (date.length() == 0 && end.length() != 0) return dateEnd + " " + end; if (dateEnd.length() == 0) { value = date + " " + start; if (end.length() > 0) value += " - " + end; } else { value = date + " " + start + " - " + dateEnd + " " + end; } if (value.length() > 0) return value; return DEFAULT_TEXT + getId(); }
From source file:de.greenrobot.daoexample.NoteActivity.java
private void addNote() { String noteText = editText.getText().toString(); editText.setText(""); final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); String comment = "Added on " + df.format(new Date()); Note note = new Note(null, noteText, comment, new Date()); noteDao.insert(note);/*from w ww.j av a2 s.c o m*/ Log.d("DaoExample", "Inserted new note, ID: " + note.getId()); cursor.requery(); }
From source file:eu.esdihumboldt.hale.io.html.HtmlMappingExporter.java
@Override protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException { this.reporter = reporter; context = new VelocityContext(); cellIds = new Identifiers<Cell>(Cell.class, false); alignment = getAlignment();/*from w ww . j a va 2 s . c om*/ URL headlinePath = this.getClass().getResource("bg-headline.png"); //$NON-NLS-1$ URL cssPath = this.getClass().getResource("style.css"); //$NON-NLS-1$ URL linkPath = this.getClass().getResource("int_link.png"); //$NON-NLS-1$ URL tooltipIcon = this.getClass().getResource("tooltip.gif"); //$NON-NLS-1$ final String filesSubDir = FilenameUtils .removeExtension(FilenameUtils.getName(getTarget().getLocation().getPath())) + "_files"; //$NON-NLS-1$ final File filesDir = new File(FilenameUtils.getFullPath(getTarget().getLocation().getPath()), filesSubDir); filesDir.mkdirs(); context.put(FILE_DIRECTORY, filesSubDir); try { init(); } catch (Exception e) { return reportError(reporter, "Initializing error", e); } File cssOutputFile = new File(filesDir, "style.css"); FileUtils.copyFile(getInputFile(cssPath), cssOutputFile); // create headline picture File headlineOutputFile = new File(filesDir, "bg-headline.png"); //$NON-NLS-1$ FileUtils.copyFile(getInputFile(headlinePath), headlineOutputFile); File linkOutputFile = new File(filesDir, "int_link.png"); //$NON-NLS-1$ FileUtils.copyFile(getInputFile(linkPath), linkOutputFile); File tooltipIconFile = new File(filesDir, "tooltip.png"); //$NON-NLS-1$ FileUtils.copyFile(getInputFile(tooltipIcon), tooltipIconFile); File htmlExportFile = new File(getTarget().getLocation().getPath()); if (projectInfo != null) { Date date = new Date(); DateFormat dfm = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); // associate variables with information data String exportDate = dfm.format(date); context.put(EXPORT_DATE, exportDate); if (projectInfo.getCreated() != null) { String created = dfm.format(projectInfo.getCreated()); context.put(CREATED_DATE, created); } context.put(PROJECT_INFO, projectInfo); } if (alignment != null) { Collection<TypeCellInfo> typeCellInfos = new ArrayList<TypeCellInfo>(); Collection<? extends Cell> cells = alignment.getTypeCells(); Iterator<? extends Cell> it = cells.iterator(); while (it.hasNext()) { final Cell cell = it.next(); // this is the collection of type cell info TypeCellInfo typeCellInfo = new TypeCellInfo(cell, alignment, cellIds, filesSubDir); typeCellInfos.add(typeCellInfo); } // put the full collection of type cell info to the context (for the // template) context.put(TYPE_CELL_INFOS, typeCellInfos); createImages(filesDir); } context.put(TOOLTIP, getParameter(TOOLTIP).as(boolean.class)); Template template; try { template = velocityEngine.getTemplate(templateFile.getName(), "UTF-8"); } catch (Exception e) { return reportError(reporter, "Could not load template", e); } FileWriter fileWriter = new FileWriter(htmlExportFile); template.merge(context, fileWriter); fileWriter.close(); reporter.setSuccess(true); return reporter; }
From source file:net.naonedbus.fragment.impl.ItineraireFragment.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); mIconPadding = getResources().getDimensionPixelSize(R.dimen.itinerary_icon_padding); if (savedInstanceState != null) { mFromLocation.set((Location) savedInstanceState.getParcelable(BUNDLE_LOCATION_FROM)); mToLocation.set((Location) savedInstanceState.getParcelable(BUNDLE_LOCATION_TO)); mDateTime.setMillis(savedInstanceState.getLong(BUNDLE_DATE_TIME)); mArriveBy = savedInstanceState.getBoolean(BUNDLE_ARRIVE_BY); mIconFromResId = savedInstanceState.getInt(BUNDLE_ICON_FROM); mIconToResId = savedInstanceState.getInt(BUNDLE_ICON_TO); mIconFromColor = savedInstanceState.getInt(BUNDLE_COLOR_FROM); mIconToColor = savedInstanceState.getInt(BUNDLE_COLOR_TO); final List<Parcelable> results = savedInstanceState.getParcelableArrayList(BUNDLE_RESULTS); for (final Parcelable parcelable : results) { mItineraryWrappers.add((ItineraryWrapper) parcelable); }/*w w w. ja v a 2 s . c om*/ } }
From source file:de.jcup.egradle.eclipse.ide.execution.GradleExecutionDelegate.java
/** * Execute and give output by given progress monitor * //from w w w. j a va2s .c o m * @param monitor * - progress monitor * @throws Exception */ public void execute(IProgressMonitor monitor) throws Exception { processExecutionResult = new ProcessExecutionResult(); try { GradleRootProject rootProject = context.getRootProject(); String commandString = context.getCommandString(); String progressDescription = "Executing gradle commands:" + commandString + " in " + context.getRootProject().getFolder().getAbsolutePath(); File folder = rootProject.getFolder(); String rootProjectFolderName = folder.getName(); String executionStartTime = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT) .format(new Date()); monitor.beginTask(progressDescription, context.getAmountOfWorkToDo()); if (monitor.isCanceled()) { return; } beforeExecutionDone(monitor); if (monitor.isCanceled()) { return; } outputHandler.output("\n" + executionStartTime + " " + progressDescription); outputHandler.output("Root project '" + rootProjectFolderName + "' executing " + commandString); if (monitor.isCanceled()) { outputHandler.output("[CANCELED]"); processExecutionResult.setCanceledByuser(true); return; } ProgressMonitorCancelStateProvider cancelStateProvider = new ProgressMonitorCancelStateProvider( monitor); context.register(cancelStateProvider); processExecutionResult = executor.execute(context); if (processExecutionResult.isOkay()) { outputHandler.output("[OK]"); } else { outputHandler.output("[FAILED]"); } afterExecutionDone(monitor); } catch (Exception e) { throw new InvocationTargetException(e); } finally { monitor.done(); } }