List of usage examples for java.text DateFormat LONG
int LONG
To view the source code for java.text DateFormat LONG.
Click Source Link
From source file:org.pentaho.platform.repository.subscription.SubscriptionHelper.java
/** * This formatter works with a date/time string with this format: May 21, 2008 8:29:21 PM * /*from ww w . j a v a2 s. co m*/ * NOTE: the formatter cannot be shared across threads (since DateFormat implementations are not guaranteed to be thread safe) or across sessions (since * different sessions may have different locales). So create a new one an each call. * * @return */ public static DateFormat getDateTimeFormatter() { return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, LocaleHelper.getLocale()); }
From source file:org.tellervo.desktop.print.SeriesReport.java
/** * iText paragraph containing created and lastmodified timestamps * //from w w w. j a va 2s . c o m * @return Paragraph */ private Paragraph getTimestampPDF() { // Set up calendar Date createdTimestamp = s.getSeries().getCreatedTimestamp().getValue().toGregorianCalendar().getTime(); Date lastModifiedTimestamp = s.getSeries().getLastModifiedTimestamp().getValue().toGregorianCalendar() .getTime(); DateFormat df1 = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); Paragraph p = new Paragraph(); p.add(new Chunk("Created: ", subSubSectionFont)); p.add(new Chunk(df1.format(createdTimestamp), bodyFont)); p.add(new Chunk("\nLast Modified: ", subSubSectionFont)); p.add(new Chunk(df1.format(lastModifiedTimestamp), bodyFont)); return p; }
From source file:com.concursive.connect.web.modules.calendar.utils.CalendarView.java
/** * Gets the Today attribute of the CalendarView object * * @return The Today value/*ww w . j a va 2 s . c o m*/ */ public String getToday() { Calendar today = Calendar.getInstance(locale); today.set(Calendar.HOUR, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); if (timeZone != null) { today.setTimeZone(timeZone); } if (locale != null) { SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat.getDateInstance(DateFormat.LONG, locale); return formatter.format(today.getTime()); } else { return (this.getMonthName(today) + " " + today.get(Calendar.DAY_OF_MONTH) + ", " + today.get(Calendar.YEAR)); } }
From source file:org.rhq.enterprise.server.system.SystemManagerBean.java
@RequiredPermission(Permission.MANAGE_SETTINGS) public ServerDetails getServerDetails(Subject subject) { CoreServerMBean coreServerMBean = LookupUtil.getCoreServer(); ServerDetails serverDetails = new ServerDetails(); serverDetails.setProductInfo(getProductInfo(subject)); HashMap<Detail, String> details = serverDetails.getDetails(); DateFormat localTimeFormatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.FULL); details.put(ServerDetails.Detail.SERVER_LOCAL_TIME, localTimeFormatter.format(new Date())); details.put(ServerDetails.Detail.SERVER_TIMEZONE, TimeZone.getDefault().getDisplayName()); details.put(ServerDetails.Detail.SERVER_HOME_DIR, coreServerMBean.getJBossServerHomeDir().getAbsolutePath()); details.put(ServerDetails.Detail.SERVER_INSTALL_DIR, coreServerMBean.getInstallDir().getAbsolutePath()); SystemDatabaseInformation dbInfo = SystemDatabaseInformation.getInstance(); details.put(ServerDetails.Detail.DATABASE_CONNECTION_URL, dbInfo.getDatabaseConnectionURL()); details.put(ServerDetails.Detail.DATABASE_DRIVER_NAME, dbInfo.getDatabaseDriverName()); details.put(ServerDetails.Detail.DATABASE_DRIVER_VERSION, dbInfo.getDatabaseDriverVersion()); details.put(ServerDetails.Detail.DATABASE_PRODUCT_NAME, dbInfo.getDatabaseProductName()); details.put(ServerDetails.Detail.DATABASE_PRODUCT_VERSION, dbInfo.getDatabaseProductVersion()); details.put(ServerDetails.Detail.CURRENT_MEASUREMENT_TABLE, dbInfo.getCurrentMeasurementTable()); details.put(ServerDetails.Detail.NEXT_MEASUREMENT_TABLE_ROTATION, dbInfo.getNextMeasurementTableRotation()); return serverDetails; }
From source file:org.kalypso.kalypsomodel1d2d.conv.results.ResultMeta1d2dHelper.java
public static void addToResultDB(final IStepResultMeta stepResultMeta, final Date stepDate, final File outputDir) { // TODO: retrieve time zone from central plugin preferences final DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG); dateFormatter.setTimeZone(KalypsoCorePlugin.getDefault().getTimeZone()); if (ResultManager.STEADY_DATE.equals(stepDate)) { stepResultMeta.setName(/*from w w w .j ava 2s .c om*/ Messages.getString("org.kalypso.kalypsomodel1d2d.conv.results.ResultMeta1d2dHelper.93")); //$NON-NLS-1$ stepResultMeta.setDescription( Messages.getString("org.kalypso.kalypsomodel1d2d.conv.results.ResultMeta1d2dHelper.94")); //$NON-NLS-1$ stepResultMeta.setStepType(IStepResultMeta.STEPTYPE.steady); stepResultMeta.setStepTime(null); } else if (ResultManager.MAXI_DATE.equals(stepDate)) { stepResultMeta.setName( Messages.getString("org.kalypso.kalypsomodel1d2d.conv.results.ResultMeta1d2dHelper.95")); //$NON-NLS-1$ stepResultMeta.setDescription( Messages.getString("org.kalypso.kalypsomodel1d2d.conv.results.ResultMeta1d2dHelper.96")); //$NON-NLS-1$ stepResultMeta.setStepType(IStepResultMeta.STEPTYPE.maximum); stepResultMeta.setStepTime(null); } else { // TODO: check for right time zone final String dateString = dateFormatter.format(stepDate); stepResultMeta.setName(Messages .getString("org.kalypso.kalypsomodel1d2d.conv.results.ResultMeta1d2dHelper.97", dateString)); //$NON-NLS-1$ stepResultMeta.setDescription( Messages.getString("org.kalypso.kalypsomodel1d2d.conv.results.ResultMeta1d2dHelper.98") //$NON-NLS-1$ + dateString); stepResultMeta.setStepType(IStepResultMeta.STEPTYPE.unsteady); stepResultMeta.setStepTime(stepDate); } stepResultMeta.setPath(new Path(outputDir.getName())); }
From source file:main.java.edu.isistan.genCom.gui.Principal.java
/** * Registra la generacin en el historial *///from www. ja va2s . c om private void cargarHistorial() { ConfiguracionAG conf = generacionCargada.getConfiguracion(); // Carga la tabla de historial DefaultTableModel dtmLog = (DefaultTableModel) tbHistorial.getModel(); dtmLog.addRow(new String[] { DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG) .format(generacionCargada.getFecha()), conf.getCruce().toString(), conf.getMutacion().toString(), conf.getSeleccion().toString(), conf.getModelo().toString(), String.valueOf(generacionCargada.getEjecuciones().size()), String.valueOf(conf.getCorte()), generacionCargada.getConfiguracion().getFitness().toString(), String.valueOf(generacionCargada.getFitnessPromedio()), String.valueOf(generacionCargada.getFitnessDesviacion()) }); }
From source file:org.opencms.ade.sitemap.CmsVfsSitemapService.java
/** * Creates a new resource info to a given model page resource.<p> * /*from ww w. j a va 2 s .c o m*/ * @param cms the current CMS context * @param modelResource the model page resource * @param locale the locale used for retrieving descriptions/titles * * @return the new resource info * * @throws CmsException if something goes wrong */ private CmsNewResourceInfo createNewResourceInfo(CmsObject cms, CmsResource modelResource, Locale locale) throws CmsException { // if model page got overwritten by another resource, reread from site path if (!cms.existsResource(modelResource.getStructureId(), CmsResourceFilter.ONLY_VISIBLE)) { modelResource = cms.readResource(cms.getSitePath(modelResource), CmsResourceFilter.ONLY_VISIBLE); } int typeId = modelResource.getTypeId(); String name = OpenCms.getResourceManager().getResourceType(typeId).getTypeName(); String title = cms.readPropertyObject(modelResource, CmsPropertyDefinition.PROPERTY_TITLE, false) .getValue(); String description = cms .readPropertyObject(modelResource, CmsPropertyDefinition.PROPERTY_DESCRIPTION, false).getValue(); try { CmsGallerySearchResult result = CmsGallerySearch.searchById(cms, modelResource.getStructureId(), locale); if (!CmsStringUtil.isEmptyOrWhitespaceOnly(result.getTitle())) { title = result.getTitle(); } if (!CmsStringUtil.isEmptyOrWhitespaceOnly(result.getDescription())) { description = result.getDescription(); } } catch (CmsException e) { LOG.warn(e.getLocalizedMessage(), e); } boolean editable = false; try { CmsResource freshModelResource = cms.readResource(modelResource.getStructureId(), CmsResourceFilter.ONLY_VISIBLE); editable = cms.hasPermissions(freshModelResource, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.DEFAULT); } catch (CmsException e) { LOG.warn(e.getLocalizedMessage(), e); } CmsNewResourceInfo info = new CmsNewResourceInfo(typeId, name, title, description, modelResource.getStructureId(), editable, description); Float navpos = null; try { CmsProperty navposProp = cms.readPropertyObject(modelResource, CmsPropertyDefinition.PROPERTY_NAVPOS, true); String navposStr = navposProp.getValue(); if (navposStr != null) { try { navpos = Float.valueOf(navposStr); } catch (NumberFormatException e) { // noop } } } catch (CmsException e) { LOG.warn(e.getLocalizedMessage(), e); } info.setNavPos(navpos); info.setDate(CmsDateUtil.getDate(new Date(modelResource.getDateLastModified()), DateFormat.LONG, getWorkplaceLocale())); info.setVfsPath(modelResource.getRootPath()); return info; }
From source file:org.gbif.ipt.task.Eml2Rtf.java
/** * Add temporal coverages section.//from w w w.j a v a 2 s . c om * * @param doc Document * @param eml EML * @throws DocumentException if problem occurs during add */ private void addTemporalCoverages(Document doc, Eml eml) throws DocumentException { if (exists(eml.getTemporalCoverages()) && !eml.getTemporalCoverages().isEmpty()) { Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFont(font); DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG); SimpleDateFormat timeFormat = new SimpleDateFormat("SSS"); SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy"); boolean firstCoverage = true; for (TemporalCoverage coverage : eml.getTemporalCoverages()) { if (coverage.getType().equals(TemporalCoverageType.SINGLE_DATE)) { if (coverage.getStartDate() != null) { if (firstCoverage) { firstCoverage = false; } else { p.add(Chunk.NEWLINE); } p.add(new Phrase(getText("rtf.tempcoverage") + ": ", fontTitle)); if (timeFormat.format(coverage.getStartDate()).equals("001")) { p.add(yearFormat.format(coverage.getStartDate())); } else { p.add(dateFormat.format(coverage.getStartDate())); } p.add(Chunk.NEWLINE); } } else if (coverage.getType() == TemporalCoverageType.DATE_RANGE) { if (coverage.getStartDate() != null && coverage.getEndDate() != null) { if (firstCoverage) { firstCoverage = false; } else { p.add(Chunk.NEWLINE); } p.add(new Phrase(getText("rtf.tempcoverage") + ": ", fontTitle)); if (timeFormat.format(coverage.getStartDate()).equals("001")) { p.add(yearFormat.format(coverage.getStartDate())); } else { p.add(dateFormat.format(coverage.getStartDate())); } p.add(" - "); if (timeFormat.format(coverage.getEndDate()).equals("001")) { p.add(yearFormat.format(coverage.getEndDate())); } else { p.add(dateFormat.format(coverage.getEndDate())); } p.add(Chunk.NEWLINE); } } } doc.add(p); p.clear(); } }
From source file:kolacer.Kolacer.java
private String[] ziskejDatumyPodleDne(String den) { String[] nedele = new String[2]; Date date = new Date(); int style = DateFormat.LONG; DateFormat df = DateFormat.getDateInstance(style, Locale.forLanguageTag("sk")); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); int pocitadlo = 0; while (!den.equals(df.format(date).split(",")[0])) { date.setTime(date.getTime() - 1000 * 60 * 60 * 24); pocitadlo++;/*from w ww . ja va 2 s.co m*/ if (pocitadlo == 7) break; } nedele[1] = sdf.format(date); date.setTime(date.getTime() - 14000 * 60 * 60 * 24); nedele[0] = sdf.format(date); return nedele; }
From source file:com.alkacon.opencms.formgenerator.CmsFormHandler.java
/** * Sends the collected data due to the configuration of the form * (email, database or both).<p>//from ww w. j a v a2 s. co m * * @return <code>true</code> if successful */ public boolean sendData() { boolean result = true; try { CmsForm data = getFormConfiguration(); data.removeCaptchaField(); // fill the macro resolver for resolving in subject and content: List<I_CmsField> fields = data.getAllFields(false, true, true); Iterator<I_CmsField> itFields = fields.iterator(); // add field values as macros while (itFields.hasNext()) { I_CmsField field = itFields.next(); if (field instanceof CmsPagingField) { continue; } String fValue = field.getValue(); if ((field instanceof CmsDynamicField) && !((field instanceof CmsDisplayField) || (field instanceof CmsHiddenDisplayField))) { fValue = data.getFieldStringValueByName(field.getName()); } if (field instanceof CmsFileUploadField) { fValue = CmsFormHandler.getTruncatedFileItemName(fValue); } m_macroResolver.addMacro(field.getLabel(), fValue); if (!field.getLabel().equals(field.getDbLabel())) { m_macroResolver.addMacro(field.getDbLabel(), fValue); } if (field instanceof CmsTableField) { Iterator<CmsFieldItem> it = field.getItems().iterator(); while (it.hasNext()) { CmsFieldItem item = it.next(); m_macroResolver.addMacro(item.getLabel(), item.getValue()); if (!item.getLabel().equals(item.getDbLabel())) { m_macroResolver.addMacro(item.getDbLabel(), item.getValue()); } } } } // add current date as macro m_macroResolver.addMacro(MACRO_DATE, CmsDateUtil.getDateTime(new Date(), DateFormat.LONG, getRequestContext().getLocale())); // send optional confirmation mail if (data.isConfirmationMailEnabled()) { if (!data.isConfirmationMailOptional() || Boolean.valueOf(getParameter(CmsForm.PARAM_SENDCONFIRMATION)).booleanValue()) { sendConfirmationMail(); } } if (data.isTransportDatabase()) { // save submitted form to database and store the uploaded files m_entryId = sendDatabase(); if (m_entryId > 0) { // successful submit result &= true; } else { // error during submit result &= false; } } if (data.isTransportEmail()) { result &= sendMail(); } } catch (Exception e) { // an error occurred during mail creation if (LOG.isErrorEnabled()) { LOG.error("An unexpected error occured.", e); } getErrors().put("sendmail", e.getMessage()); result = false; } return result; }