List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:de.iteratec.iteraplan.businesslogic.exchange.nettoExport.OverviewPageColumnStructure.java
/**{@inheritDoc}**/ @Override/* ww w.j a v a 2 s . c o m*/ public Object resolveValue(Object bean) { // Same logic like in Results.jsp here: BeanWrapperImpl wrapper = new BeanWrapperImpl(false); wrapper.setWrappedInstance(bean); Object resolvedObject = wrapper.getPropertyValue(columnDefinition.getBeanPropertyPath()); AttributeType attrType = columnDefinition.getAttributeType(); boolean multiValueType = (attrType instanceof MultiassignementType) && ((MultiassignementType) attrType).isMultiassignmenttype(); if (attrType != null) { if (resolvedObject instanceof List<?>) { List<?> allValues = (List<?>) resolvedObject; if (multiValueType) { List<String> attributeValues = Lists.newArrayList(); for (Object attrObj : allValues) { if (attrObj instanceof DateAV) { Date dateValue = ((DateAV) attrObj).getValue(); attributeValues.add(dateValue.toString()); } else if (attrObj instanceof ResponsibilityAV) { attributeValues.add(((ResponsibilityAV) attrObj).getName()); } else { attributeValues.add(((AttributeValue) attrObj).getValueString()); } } return Joiner.on(MULTIVALUE_SEPARATOR).join(attributeValues); } else { if (allValues == null || allValues.size() == 0) { return NOT_FOUND; } Object singleValue = allValues.get(0); if (singleValue instanceof ResponsibilityAV) { return ((ResponsibilityAV) singleValue).getName(); } else { return ((AttributeValue) singleValue).getValue(); } } } } else { if ("direction".equals(columnDefinition.getModelPath()) && (resolvedObject instanceof String)) { Direction directionForValue = Direction.getDirectionForValue(String.valueOf(resolvedObject)); if (directionForValue != null) { return SHOW_DIRECTION_ARROWS ? directionForValue.toString() : directionForValue.name(); } } if (columnDefinition.isInternationalized()) { return MessageAccess.getString(String.valueOf(resolvedObject)); } return String.valueOf(resolvedObject); } return StringUtils.defaultString(String.valueOf(resolvedObject), NOT_FOUND); }
From source file:com.springsource.insight.plugin.mail.MessageSendOperationCollectionAspectTest.java
private void testSendMessage(int port) { JavaMailSenderImpl sender = new JavaMailSenderImpl(); sender.setHost(NetworkAddressUtil.LOOPBACK_ADDRESS); sender.setProtocol(JavaMailSenderImpl.DEFAULT_PROTOCOL); sender.setPort(port);//from w w w. j a va 2 s .co m SimpleMailMessage message = new SimpleMailMessage(); message.setFrom("from@com.springsource.insight.plugin.mail"); message.setTo("to@com.springsource.insight.plugin.mail"); message.setCc("cc@com.springsource.insight.plugin.mail"); message.setBcc("bcc@com.springsource.insight.plugin.mail"); Date now = new Date(System.currentTimeMillis()); message.setSentDate(now); message.setSubject(now.toString()); message.setText("Test at " + now.toString()); sender.send(message); Operation op = getLastEntered(); assertNotNull("No operation extracted", op); assertEquals("Mismatched operation type", MailDefinitions.SEND_OPERATION, op.getType()); assertEquals("Mismatched protocol", sender.getProtocol(), op.get(MailDefinitions.SEND_PROTOCOL, String.class)); assertEquals("Mismatched host", sender.getHost(), op.get(MailDefinitions.SEND_HOST, String.class)); if (port == -1) { assertEquals("Mismatched default port", 25, op.getInt(MailDefinitions.SEND_PORT, (-1))); } else { assertEquals("Mismatched send port", sender.getPort(), op.getInt(MailDefinitions.SEND_PORT, (-1))); } if (getAspect().collectExtraInformation()) { assertAddresses(op, MailDefinitions.SEND_SENDERS, 1); assertAddresses(op, MailDefinitions.SEND_RECIPS, 3); OperationMap details = op.get(MailDefinitions.SEND_DETAILS, OperationMap.class); assertNotNull("No details extracted", details); assertEquals("Mismatched subject", message.getSubject(), details.get(MailDefinitions.SEND_SUBJECT, String.class)); } }
From source file:net.nelz.simplesm.test.dao.TestDAOImpl.java
@ReadThroughSingleCache(namespace = "Alpha", expiration = 30) public String getDateString(@ParameterValueKeyProvider final String key) { final Date now = new Date(); try {/*from w w w. j a va 2 s .co m*/ Thread.sleep(1500); } catch (InterruptedException ex) { } return now.toString() + ":" + now.getTime(); }
From source file:edu.pitt.resumecore.Prescription.java
/** * @param expires the expires to set/*from w ww . j a v a 2s.c o m*/ */ public void setExpires(Date expires) { String sql = "UPDATE emr.prescriptions SET expires = '" + StringUtilities.cleanMySqlInsert(expires.toString()) + "' "; sql += "WHERE prescriptionId = '" + this.prescriptionId + "';"; db.executeQuery(sql); this.expires = expires; }
From source file:mx.gob.cfe.documentos.web.DepuracionController.java
/** * Metodo utilizado para generrar el pdf * * @param tipo//from w w w . j a v a 2 s .co m * @param documentos * @param response * @throws JRException * @throws IOException */ private void generaReporte(String tipo, List<Documento> documentos, HttpServletResponse response) throws JRException, IOException { log.debug("Generando reporte {}", tipo); byte[] archivo = null; switch (tipo) { case "PDF": archivo = generaPdf(documentos); response.setContentType("application/pdf"); Date fecha = new Date(); response.addHeader("Content-Disposition", "attachment; filename=" + fecha.toString() + "depuracion.pdf"); break; } if (archivo != null) { response.setContentLength(archivo.length); try (BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream())) { bos.write(archivo); bos.flush(); } } }
From source file:org.apache.airavata.xbaya.ui.dialogs.monitor.MonitorWindow.java
/** * Shows the notification./*from w ww. j ava 2 s. c o m*/ * * @param event * The notification to show */ public void show(XmlElement event) { Date timestamp = MonitorUtil.getTimestamp(event); if (timestamp != null) { this.timeTextField.setText(timestamp.toString()); } else { this.timeTextField.setText(""); } this.idTextField.setText(MonitorUtil.getNodeID(event)); this.statusTextField.setText(MonitorUtil.getStatus(event)); // Show the raw XML for now. messageText = XMLUtil.BUILDER.serializeToStringPretty(event); this.messageTextArea.setText(StringUtil .createHTMLUrlTaggedString2(StringEscapeUtils.escapeHtml(messageText), StringUtil.getURLS(messageText)) .replaceAll(Pattern.quote(" "), " ").replaceAll(Pattern.quote("\n"), "<br />\n")); this.dialog.show(); this.dialog.getDialog().setSize(600, 800); }
From source file:com.bstek.dorado.data.type.DateDataTypeTest.java
public void testConvertFromText() { String text;/*from w ww.j a va 2 s . c o m*/ Date date; text = null; date = (Date) dateDataType.fromText(text); assertNull(date); text = "1976-04-03"; date = (Date) dateDataType.fromText(text); assertTrue(date.toString().indexOf("1976") >= 0); text = "1949-02-10"; date = (Date) dateDataType.fromText(text); assertTrue(date.toString().indexOf("1949") >= 0); text = "13:30:58"; date = (Date) dateDataType.fromText(text); assertTrue(date.toString().indexOf("13") >= 0); text = "1976-04-03 13:30:58"; date = (Date) dateDataType.fromText(text); assertTrue(date.toString().indexOf("1976") >= 0); assertTrue(date.toString().indexOf("13") >= 0); text = String.valueOf(System.currentTimeMillis()); date = (Date) dateDataType.fromText(text); assertNotNull(date); }
From source file:com.google.appengine.tck.appidentity.AppIdentityServiceTest.java
private String dateDebugStr(String comment, Date date) { return comment + "=" + date.toString() + ", " + date.getTime() + ")"; }
From source file:org.apache.usergrid.apm.service.CrashLogDBService.java
/** * Use this to get all crash logs for a given app since given time * @param instaOpsAppId//from ww w .j a v a 2s .c o m * @param since */ @SuppressWarnings("unchecked") public List<CrashLogDetails> getCrashLogs(Long instaOpsAppId, Date since) { log.info("getting crash logs for app " + instaOpsAppId + " since " + since.toString()); Long minuteValue = since.getTime() / 1000 / 60; String queryString = "FROM CrashLogDetails m where m.appId = :appId and m.endMinute >= :minuteValue "; List<CrashLogDetails> crashLogs = null; Session session = null; Transaction transaction = null; try { session = ServiceFactory.getAnalyticsHibernateSession(); transaction = session.beginTransaction(); Query query = session.createQuery(queryString); query.setParameter("appId", instaOpsAppId); query.setParameter("minuteValue", minuteValue); crashLogs = query.list(); transaction.commit(); } catch (Exception e) { e.printStackTrace(); transaction.rollback(); throw new HibernateException("Problem gettign crash logs for app " + instaOpsAppId, e); } return crashLogs; }
From source file:org.collectionspace.chain.csp.persistence.TestData.java
private JSONObject addData(String jsonfile, String field) { JSONObject userObj = getJSON(jsonfile); try {//from w ww .j a v a 2 s.c o m String stuff = userObj.getString(field); Date d = new Date(); userObj.put(field, stuff + d.toString()); } catch (JSONException e) { errored(e); } return userObj; }