List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:hr.fer.zemris.vhdllab.entity.ClientLog.java
public ClientLog(String userId, String data) { super(userId, null); setData(data);/* w ww. ja v a2s . c om*/ Date timestamp = new Date(); setCreatedOn(timestamp); setName(timestamp.toString()); }
From source file:com.avanza.astrix.service.registry.pu.SpaceServiceRegistryEntryRepository.java
@Override public void insertOrUpdate(AstrixServiceRegistryEntry entry, long lease) { SpaceServiceRegistryEntry spaceEntry = new SpaceServiceRegistryEntry(); spaceEntry.setApiType(entry.getServiceBeanType()); ServiceKey serviceKey = new ServiceKey(entry.getServiceBeanType(), entry.getServiceProperties().get(ServiceProperties.QUALIFIER)); spaceEntry.setServiceKey(serviceKey); String applicationInstanceId = entry.getServiceProperties().get(ServiceProperties.APPLICATION_INSTANCE_ID); ServiceProviderKey serviceProviderKey = ServiceProviderKey.create(serviceKey, applicationInstanceId); spaceEntry.setServiceProviderKey(serviceProviderKey); spaceEntry.setProperties(entry.getServiceProperties()); Map<String, String> metadata = new HashMap<>(); Date now = new Date(); metadata.put("lastLeaseRenewalTime", now.toString()); metadata.put("leaseExpireTime", new Date(now.getTime() + lease).toString()); spaceEntry.setServiceMetadata(metadata); gigaSpace.write(spaceEntry, lease);//w w w. j a va 2 s. c o m }
From source file:org.cesecore.certificates.ca.internal.CertificateValidity.java
public static void checkPrivateKeyUsagePeriod(final X509Certificate cert, final Date checkDate) throws CAOfflineException { if (cert != null) { final PrivateKeyUsagePeriod pku = CertTools.getPrivateKeyUsagePeriod(cert); if (pku != null) { final ASN1GeneralizedTime notBefore = pku.getNotBefore(); final Date pkuNotBefore; final Date pkuNotAfter; try { if (notBefore == null) { pkuNotBefore = null; } else { pkuNotBefore = notBefore.getDate(); }/*from ww w . j a va 2s . c om*/ if (log.isDebugEnabled()) { log.debug("PrivateKeyUsagePeriod.notBefore is " + pkuNotBefore); } if (pkuNotBefore != null && checkDate.before(pkuNotBefore)) { final String msg = intres.getLocalizedMessage("createcert.privatekeyusagenotvalid", pkuNotBefore.toString(), cert.getSubjectDN().toString()); if (log.isDebugEnabled()) { log.debug(msg); } throw new CAOfflineException(msg); } final ASN1GeneralizedTime notAfter = pku.getNotAfter(); if (notAfter == null) { pkuNotAfter = null; } else { pkuNotAfter = notAfter.getDate(); } } catch (ParseException e) { throw new IllegalStateException("Could not parse dates.", e); } if (log.isDebugEnabled()) { log.debug("PrivateKeyUsagePeriod.notAfter is " + pkuNotAfter); } if (pkuNotAfter != null && checkDate.after(pkuNotAfter)) { final String msg = intres.getLocalizedMessage("createcert.privatekeyusageexpired", pkuNotAfter.toString(), cert.getSubjectDN().toString()); if (log.isDebugEnabled()) { log.debug(msg); } throw new CAOfflineException(msg); } } else if (log.isDebugEnabled()) { log.debug("No PrivateKeyUsagePeriod available in certificate."); } } else if (log.isDebugEnabled()) { log.debug("No CA certificate available, not checking PrivateKeyUsagePeriod."); } }
From source file:com.softrism.tortlets.batch.JobLauncherDetails.java
@SuppressWarnings("unchecked") protected void executeInternal(JobExecutionContext contextFromQuartz) { Map<String, Object> jobDataMap = contextFromQuartz.getMergedJobDataMap(); Date now = new Date(); jobDataMap.put("TIME_STAMP", now.toString()); // Add date stamp in map // Based on current time, which one timezone 2 am is it? // if its PST 2 am , add date + PST String jobName = (String) jobDataMap.get(JOB_NAME); log.info("Quartz trigger firing with Spring Batch jobName=" + jobName); JobParameters jobParameters = getJobParametersFromJobMap(jobDataMap); try {/*from www . j a v a 2 s . c om*/ jobLauncher.run(jobLocator.getJob(jobName), jobParameters); } catch (JobExecutionException e) { log.error("Could not execute job.", e); } }
From source file:com.maxl.java.aips2xml.Aips2Xml.java
static String addHeaderToXml(String xml_str) { Document mDoc = Jsoup.parse("<kompendium>\n" + xml_str + "</kompendium>"); mDoc.outputSettings().escapeMode(EscapeMode.xhtml); mDoc.outputSettings().prettyPrint(true); mDoc.outputSettings().indentAmount(4); // Add date//from w ww . ja v a 2 s. c o m Date df = new Date(); String date_str = df.toString(); mDoc.select("kompendium").first().prependElement("date"); mDoc.select("date").first().text(date_str); // Add language mDoc.select("date").after("<lang></lang>"); if (DB_LANGUAGE.equals("de")) mDoc.select("lang").first().text("DE"); else if (DB_LANGUAGE.equals("fr")) mDoc.select("lang").first().text("FR"); // Fool jsoup.parse which seems to have its own "life" mDoc.select("tbody").unwrap(); Elements img_elems = mDoc.select("img"); for (Element img_e : img_elems) { if (!img_e.hasAttr("src")) img_e.unwrap(); } mDoc.select("img").tagName("image"); String final_xml_str = mDoc.select("kompendium").first().outerHtml(); return final_xml_str; }
From source file:nz.co.senanque.functions.FunctionTest.java
@Test public void test1() throws Exception { ValidationSession validationSession = m_validationEngine.createSession(); Customer customer = m_customerDAO.createCustomer(); validationSession.bind(customer);/* w w w . java 2s . c o m*/ Invoice invoice = new Invoice(); invoice.setDescription("test invoice"); customer.setOneInvoice(invoice); customer.setAmount(130); Double d = invoice.getAmount(); // proves r1 fired okay assertEquals(130L, d.longValue()); long days = invoice.getDays(); // proves r2 fired okay assertEquals(3834L, days); Date revisedDate = invoice.getRevisedDate(); assertEquals("Mon Apr 24 00:00:00 NZST 2000", revisedDate.toString()); }
From source file:com.cegeka.GethBean.java
public void processMessage(Message message, Exchange exchange) { Date now = new Date(); System.out.print("[" + now.toString() + "]Someone sent me this: " + message + "\n"); }
From source file:net.pms.util.TempFileMgr.java
private void dumpFile() throws IOException { try (FileOutputStream out = new FileOutputStream(cleanFile())) { Date now = new Date(); String n = "## " + now.toString() + "\n"; out.write("#########\n".getBytes()); out.write(n.getBytes());/*from w ww .j a v a2s . co m*/ for (File f : files.keySet()) { String str = f.getAbsolutePath() + "," + files.get(f) + "\n"; out.write(str.getBytes()); } out.flush(); } }
From source file:com.mg.framework.utils.MiscUtils.java
/** * ? ? ?? ? <code>DATE, DATETIME, TIME</code> * * @param value /* w ww . j a v a2 s. c o m*/ * @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.bigdata.hbase.HBase.java
public void writeIntoTable(String colFamily, String colQualifier, String value) throws Exception { Connection c = pool.borrowObject(); TableName tableName = TableName.valueOf(this.table); Table t = c.getTable(tableName);//from ww w. j a v a 2 s. c o m TimeStamp ts = new TimeStamp(new Date()); Date d = ts.getDate(); Put p = new Put(Bytes.toBytes(d.toString())); p.addColumn(Bytes.toBytes(colFamily), Bytes.toBytes(colQualifier), Bytes.toBytes(value)); t.put(p); t.close(); pool.returnObject(c); }