List of usage examples for org.joda.time DateTime toString
public String toString(String pattern)
From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserGroupRenderer.java
License:Open Source License
/** * See Interface for functional description. * */// w w w . j ava 2s . c o m @Override public String renderGrant(final RoleGrant grant) throws WebserverSystemException { final Map<String, Object> values = new HashMap<String, Object>(); values.put("isRootGrant", XmlTemplateProviderConstants.TRUE); values.put("grantNamespacePrefix", Constants.GRANTS_NS_PREFIX); values.put("grantNamespace", Constants.GRANTS_NS_URI); values.put(XmlTemplateProviderConstants.ESCIDOC_PROPERTIES_NS_PREFIX, Constants.PROPERTIES_NS_PREFIX); values.put(XmlTemplateProviderConstants.ESCIDOC_PROPERTIES_NS, Constants.PROPERTIES_NS_URI); values.put(XmlTemplateProviderConstants.ESCIDOC_SREL_NS_PREFIX, Constants.STRUCTURAL_RELATIONS_NS_PREFIX); values.put(XmlTemplateProviderConstants.ESCIDOC_SREL_NS, Constants.STRUCTURAL_RELATIONS_NS_URI); values.put("grantTitle", grant.getTitle()); values.put("grantHref", grant.getHref()); values.put("grantId", grant.getId()); if (grant.getUserAccountByUserId() != null) { values.put("grantUserTitle", grant.getUserAccountByUserId().getName()); values.put("grantUserHref", grant.getUserAccountByUserId().getHref()); values.put("grantUserId", grant.getUserAccountByUserId().getId()); } if (grant.getUserGroupByGroupId() != null) { values.put("grantGroupTitle", grant.getUserGroupByGroupId().getName()); values.put("grantGroupHref", grant.getUserGroupByGroupId().getHref()); values.put("grantGroupId", grant.getUserGroupByGroupId().getId()); } final EscidocRole escidocRole = grant.getEscidocRole(); values.put("grantRoleTitle", escidocRole.getRoleName()); final String roleId = escidocRole.getId(); values.put("grantRoleHref", XmlUtility.getRoleHref(roleId)); values.put("grantRoleId", roleId); values.put("grantObjectRefHref", grant.getObjectHref()); values.put("grantObjectRefTitle", grant.getObjectTitle()); values.put("grantObjectRefId", grant.getObjectId()); DateTime creationDateTime = new DateTime(grant.getCreationDate()); creationDateTime = creationDateTime.withZone(DateTimeZone.UTC); final String creationDate = creationDateTime.toString(Constants.TIMESTAMP_FORMAT); values.put("grantCreationDate", creationDate); values.put("grantCreatedByTitle", grant.getUserAccountByCreatorId().getName()); values.put("grantCreatedByHref", grant.getUserAccountByCreatorId().getHref()); values.put("grantCreatedById", grant.getUserAccountByCreatorId().getId()); values.put("grantRemark", grant.getGrantRemark()); final Date revocationDate = grant.getRevocationDate(); if (revocationDate != null) { DateTime revokationDateTime = new DateTime(grant.getRevocationDate()); revokationDateTime = revokationDateTime.withZone(DateTimeZone.UTC); final String revokationDate = revokationDateTime.toString(Constants.TIMESTAMP_FORMAT); values.put("grantRevocationDate", revokationDate); final UserAccount revokedBy = grant.getUserAccountByRevokerId(); values.put("grantRevokedByHref", revokedBy.getHref()); values.put("grantRevokedById", revokedBy.getId()); values.put("grantRevokedByTitle", revokedBy.getName()); values.put("grantRevocationRemark", grant.getRevocationRemark()); } addEscidocBaseUrl(values); DateTime lmdDateTime = new DateTime(grant.getLastModificationDate()); lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC); final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT); values.put("grantLastModificationDate", lmd); return getUserGroupXmlProvider().getGrantXml(values); }
From source file:de.escidoc.core.aa.business.renderer.VelocityXmlUserGroupRenderer.java
License:Open Source License
/** * See Interface for functional description. * * @see de.escidoc.core.aa.business.renderer.interfaces.UserGroupRendererInterface * #renderResources(de.escidoc.core.aa.business.UserGroup) *///w w w .ja va 2s. co m @Override public String renderResources(final UserGroup userGroup) throws WebserverSystemException { final Map<String, Object> values = new HashMap<String, Object>(); values.put("isRootResources", XmlTemplateProviderConstants.TRUE); addResourcesValues(userGroup, values); addCommonValues(values); DateTime lmdDateTime = new DateTime(userGroup.getLastModificationDate()); lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC); final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT); values.put("userGroupLastModificationDate", lmd); return getUserGroupXmlProvider().getResourcesXml(values); }
From source file:de.escidoc.core.sm.business.renderer.VelocityXmlAggregationDefinitionRenderer.java
License:Open Source License
/** * Adds the values of the {@link AggregationDefinition} to the provided {@link Map}. * * @param aggregationDefinition The {@link AggregationDefinition}. * @param values The {@link Map} to add the values to. * @throws SystemException Thrown in case of an internal error. */// w ww . j av a 2s .co m private static void addAggregationDefinitionValues(final AggregationDefinition aggregationDefinition, final Map<String, Object> values) { DateTime createDateTime = new DateTime(aggregationDefinition.getCreationDate()); createDateTime = createDateTime.withZone(DateTimeZone.UTC); final String create = createDateTime.toString(Constants.TIMESTAMP_FORMAT); values.put("aggregationDefinitionCreationDate", create); values.put("aggregationDefinitionCreatedById", aggregationDefinition.getCreatorId()); values.put("aggregationDefinitionCreatedByTitle", "user " + aggregationDefinition.getCreatorId()); values.put("aggregationDefinitionCreatedByHref", XmlUtility.getUserAccountHref(aggregationDefinition.getCreatorId())); values.put("aggregationDefinitionId", aggregationDefinition.getId()); values.put("aggregationDefinitionName", aggregationDefinition.getName()); values.put("aggregationDefinitionHref", XmlUtility.getAggregationDefinitionHref(aggregationDefinition.getId())); values.put("aggregationDefinitionScopeId", aggregationDefinition.getScope().getId()); values.put("aggregationDefinitionScopeTitle", aggregationDefinition.getScope().getName()); values.put("aggregationDefinitionScopeHref", XmlUtility.getScopeHref(aggregationDefinition.getScope().getId())); addAggregationTableValues(aggregationDefinition.getAggregationTables(), values); addStatisticDataSelectorValues(aggregationDefinition.getAggregationStatisticDataSelectors(), values); }
From source file:de.escidoc.core.sm.business.renderer.VelocityXmlReportDefinitionRenderer.java
License:Open Source License
/** * Adds the values of the {@link ReportDefinition} to the provided {@link Map}. * * @param reportDefinition The {@link ReportDefinition}. * @param values The {@link Map} to add the values to. * @throws SystemException Thrown in case of an internal error. *///from w ww . ja va 2s.c o m private static void addReportDefinitionValues(final ReportDefinition reportDefinition, final Map<String, Object> values) { DateTime createDateTime = new DateTime(reportDefinition.getCreationDate()); createDateTime = createDateTime.withZone(DateTimeZone.UTC); final String create = createDateTime.toString(Constants.TIMESTAMP_FORMAT); DateTime lmdDateTime = new DateTime(reportDefinition.getLastModificationDate()); lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC); final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT); values.put("reportDefinitionCreationDate", create); values.put("reportDefinitionCreatedById", reportDefinition.getCreatorId()); values.put("reportDefinitionCreatedByTitle", "user " + reportDefinition.getCreatorId()); values.put("reportDefinitionCreatedByHref", XmlUtility.getUserAccountHref(reportDefinition.getCreatorId())); values.put("reportDefinitionLastModificationDate", lmd); values.put("reportDefinitionModifiedById", reportDefinition.getModifiedById()); values.put("reportDefinitionModifiedByTitle", "user " + reportDefinition.getModifiedById()); values.put("reportDefinitionModifiedByHref", XmlUtility.getUserAccountHref(reportDefinition.getModifiedById())); values.put("reportDefinitionId", reportDefinition.getId()); values.put("reportDefinitionName", reportDefinition.getName()); values.put("reportDefinitionHref", XmlUtility.getReportDefinitionHref(reportDefinition.getId())); values.put("reportDefinitionScopeId", reportDefinition.getScope().getId()); values.put("reportDefinitionScopeTitle", reportDefinition.getScope().getName()); values.put("reportDefinitionScopeHref", XmlUtility.getScopeHref(reportDefinition.getScope().getId())); values.put("reportDefinitionSql", reportDefinition.getSql()); addReportDefinitionRoleValues(reportDefinition.getReportDefinitionRoles(), values); }
From source file:de.escidoc.core.sm.business.renderer.VelocityXmlReportRenderer.java
License:Open Source License
/** * Adds the values of the database-query to the provided {@link Map}. * * @param dbResult The dbResult./*from ww w. j a v a2s . co m*/ * @param values The {@link Map} to add the values to. * @throws SystemException Thrown in case of an internal error. */ private static void addDataValues(final Collection dbResult, final Map<String, Object> values) { final Collection<List<HashMap<String, Object>>> recordsList = new ArrayList<List<HashMap<String, Object>>>(); if (dbResult != null && !dbResult.isEmpty()) { // Iterate records from database for (final Object aDbResult : dbResult) { final List<HashMap<String, Object>> recordFieldList = new ArrayList<HashMap<String, Object>>(); final Map map = (Map) aDbResult; // iterate all fields of one record for (final Object o : map.keySet()) { final String fieldname = (String) o; // depending on the fieldtype, // write stringvalue, datevalue or decimalvalue-element if (map.get(fieldname) != null) { final HashMap<String, Object> recordFieldMap = new HashMap<String, Object>(); recordFieldMap.put("fieldname", fieldname); final String classname = map.get(fieldname).getClass().getSimpleName(); if ("BigDecimal".equals(classname)) { recordFieldMap.put("decimalvalue", map.get(fieldname).toString()); } else if ("Timestamp".equals(classname)) { DateTime dateTime = new DateTime(map.get(fieldname)); dateTime = dateTime.withZone(DateTimeZone.UTC); final String dateString = dateTime.toString(Constants.TIMESTAMP_FORMAT); recordFieldMap.put("datevalue", dateString); } else { recordFieldMap.put("stringvalue", map.get(fieldname)); } // Add field to record recordFieldList.add(recordFieldMap); } } // add record to recordsVm if (!recordFieldList.isEmpty()) { recordsList.add(recordFieldList); } } } values.put("records", recordsList); }
From source file:de.escidoc.core.sm.business.renderer.VelocityXmlScopeRenderer.java
License:Open Source License
/** * Adds the values of the {@link Scope} to the provided {@link Map}. * * @param scope The {@link Scope}./*from w ww . j a va 2 s . c o m*/ * @param values The {@link Map} to add the values to. * @throws SystemException Thrown in case of an internal error. */ private static void addScopeValues(final Scope scope, final Map<String, Object> values) { DateTime createDateTime = new DateTime(scope.getCreationDate()); createDateTime = createDateTime.withZone(DateTimeZone.UTC); final String create = createDateTime.toString(Constants.TIMESTAMP_FORMAT); DateTime lmdDateTime = new DateTime(scope.getLastModificationDate()); lmdDateTime = lmdDateTime.withZone(DateTimeZone.UTC); final String lmd = lmdDateTime.toString(Constants.TIMESTAMP_FORMAT); values.put("scopeCreationDate", create); values.put("scopeCreatedById", scope.getCreatorId()); values.put("scopeCreatedByTitle", "user " + scope.getCreatorId()); values.put("scopeCreatedByHref", XmlUtility.getUserAccountHref(scope.getCreatorId())); values.put("scopeLastModificationDate", lmd); values.put("scopeModifiedById", scope.getModifiedById()); values.put("scopeModifiedByTitle", "user " + scope.getModifiedById()); values.put("scopeModifiedByHref", XmlUtility.getUserAccountHref(scope.getModifiedById())); values.put("scopeId", scope.getId()); values.put("scopeName", scope.getName()); values.put("scopeHref", XmlUtility.getScopeHref(scope.getId())); values.put("scopeType", scope.getScopeType()); }
From source file:de.gfz_potsdam.datasync.Datasync.java
private void downloadItemFiles(String basedir, ItemMemberRef ref, Container parent) throws Exception { Item item = (Item) srv.getResourceById(ref.getObjid()); for (MetadataRecord mdr : item.getMetadataRecords()) { if (mdr.getName().equals("escidoc")) continue; log.log(Level.WARNING, "FIXME - download of Metadata not yet done"); }//from w w w . j av a 2 s. c om File syncdir = new File(directory + File.separator + basedir); for (Component component : item.getComponents()) { String filename = component.getProperties().getFileName(); File syncfile = new File(directory + File.separator + basedir + File.separator + filename); StringBuilder suffix = new StringBuilder(); if (syncfile.exists()) { if (App.db.localIsNewer(basedir + File.separator + filename, item.getObjid(), syncfile.lastModified())) { //local and remote file have changed suffix.append("-"); suffix.append(item.getObjid()); suffix.append(":"); suffix.append(item.getProperties().getVersion().getNumber()); suffix.append("-"); DateTime mdate = new DateTime(item.getLastModificationDate()); suffix.append(mdate.toString("YYYYMMdd-HHmmss")); syncfile = new File( directory + File.separator + basedir + File.separator + filename + suffix.toString()); } else if (!App.db.remoteIsNewer(basedir + File.separator + filename, item.getObjid(), item.getLastModificationDate())) { // do not download we downloaded before continue; } } else { //file was downloaded and locally deleted if (App.db.entryExists(basedir + File.separator + filename, item.getObjid())) continue; } //Download component HttpClient client = new HttpClient(); String url = auth.getServiceAddress() + component.getContent().getXLinkHref().replaceAll("^/", ""); GetMethod method = new GetMethod(url); method.setRequestHeader("Cookie", "escidocCookie=" + auth.getHandle()); try { log.log(Level.INFO, "downloading : {0}", new Object[] { syncfile.getAbsolutePath() }); client.executeMethod(method); InputStream is = method.getResponseBodyAsStream(); FileOutputStream file = new FileOutputStream(syncfile); byte[] buffer = new byte[4096]; int len; while ((len = is.read(buffer, 0, buffer.length)) != -1) { file.write(buffer, 0, len); } file.flush(); file.getFD().sync(); file.close(); } finally { method.releaseConnection(); } //update DB for non-conflicting files if (suffix.length() == 0) { App.db.storeMapping(basedir + File.separator + syncfile.getName(), item.getObjid(), syncfile.lastModified(), item.getLastModificationDate(), SyncDB.FILE); App.db.storeMapping(basedir, parent.getObjid(), syncdir.lastModified(), parent.getLastModificationDate(), SyncDB.DIRECTORY); } } }
From source file:de.openali.odysseus.chart.ext.base.axisrenderer.DateTimeLabelCreator.java
License:Open Source License
/** * @see de.openali.odysseus.chart.ext.base.axisrenderer.ILabelCreator#getLabel(java.lang.Number, * de.openali.odysseus.chart.framework.model.data.IDataRange) *///from w w w . java 2 s. c om @Override public String getLabel(final Number value, final IDataRange<Number> range) { // final TimeZone kalypsoTZ = KalypsoCorePlugin.getDefault().getTimeZone(); // final FixedDateTimeZone jodaTZ = new FixedDateTimeZone( kalypsoTZ.getID(), null, kalypsoTZ.getOffset( value.longValue() ), kalypsoTZ.getOffset( value.longValue() ) ); // final IDateTimeAxisField axisField = m_dateTimeFieldProvider.getDateTimeAxisField(range); final DateTimeZone zone = DateTimeZone.forTimeZone(KalypsoCorePlugin.getDefault().getTimeZone()); final DateTime dateTime = new DateTime(value.longValue(), zone); return dateTime.toString(axisField.getFormatString()); }
From source file:de.tastykatana.zeiterfassung.activity.MainActivity.java
/** * exports a Stundenzettel for the current month to /Documents/Stundenzettel *//*from ww w. j a v a 2 s.co m*/ private void exportStundenzettel(DateTime month) { PdfDocument doc = new PdfDocument(); PdfDocument.PageInfo pageInfo = new PdfDocument.PageInfo.Builder(595, 842, 1).create(); // start a page PdfDocument.Page page = doc.startPage(pageInfo); // assemble Layout for Stundenzettel ViewGroup stundenzettel = MyApp.zeiterfassung.buildStundenzettelForMonth(this, DateTime.now(), MyApp.getPrefs().getBoolean(getString(R.string.correct_start_end_preference_key), false)); // do some magic and draw the main layout to the page int measuredWidth = View.MeasureSpec.makeMeasureSpec(575, View.MeasureSpec.EXACTLY); int measuredHeight = View.MeasureSpec.makeMeasureSpec(822, View.MeasureSpec.EXACTLY); stundenzettel.measure(measuredWidth, measuredHeight); stundenzettel.layout(0, 0, stundenzettel.getMeasuredWidth(), stundenzettel.getMeasuredHeight()); page.getCanvas().translate(20, 20); stundenzettel.draw(page.getCanvas()); // finish the page doc.finishPage(page); // write the document content to storage String fileName = "Stundenzettel_" + month.toString("MM.yyyy") + "_" + MyApp.getPrefs().getString(getString(R.string.user_name_preference_key), "") + "_" + MyApp.getPrefs().getString(getString(R.string.job_name_preference_key), "") + ".pdf"; final File outFile = new File(MyApp.getPrefs().getString(getString(R.string.filepath_preference_key), getString(R.string.filepath_default_value)), fileName); outFile.getParentFile().mkdirs(); try { doc.writeTo(new FileOutputStream(outFile)); Log.d("export", "file '" + outFile.getName() + "' saved in '" + outFile.getAbsolutePath() + "'"); Snackbar.make(coordLayout, getString(R.string.file_exported_snackbar, outFile.getAbsolutePath()), Snackbar.LENGTH_INDEFINITE).setAction(R.string.share, new View.OnClickListener() { @Override public void onClick(View v) { SharingHelper.sharePdf(outFile, MainActivity.this); } }).show(); } catch (IOException e) { e.printStackTrace(); Toast.makeText(this, R.string.stundenzettelExportFailed, Toast.LENGTH_SHORT).show(); } doc.close(); }
From source file:dk.dma.epd.common.text.Formatter.java
License:Apache License
public static String formatYodaTime(DateTime time) { DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MMMM, HH:mm"); return time.toString(fmt); }