List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:ch.ksfx.web.pages.ViewTimeSeries.java
public StreamResponse onGraph() { Date date = new Date(); System.out.println("[GRAPH] Creating new Graph start (" + timeSeries.getId() + ") " + date.toString()); if (GraphSemaphore.available.availablePermits() == 0) { System.out.println("[GRAPH] Not creating graph, cannot get semaphore " + date.toString() + " (" + timeSeries.getId() + ")"); return null; }/*w ww . ja v a 2s. c o m*/ try { GraphSemaphore.available.acquire(); return new ImageStreamResponse("image/jpeg", observationChartGenerator.renderChart(generateGraph(), 700, 500)); } catch (Exception e) { logger.error("[GRAPH] Cannot create graph " + date.toString(), e); return null; } finally { System.out .println("[GRAPH] Creating new Graph finished (" + timeSeries.getId() + ") " + date.toString()); GraphSemaphore.available.release(); } }
From source file:org.alfresco.module.org_alfresco_module_rm.script.TransferReportPost.java
/** * Generates a File containing the JSON representation of a transfer report. * * @param transferNode The transfer node * @return File containing JSON representation of a transfer report * @throws IOException//w w w . j av a2 s . com */ File generateHTMLTransferReport(NodeRef transferNode) throws IOException { File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX); Writer writer = null; try { // get all 'transferred' nodes NodeRef[] itemsToTransfer = getTransferNodes(transferNode); if (logger.isDebugEnabled()) { logger.debug("Generating HTML transfer report for " + itemsToTransfer.length + " items into file: " + report.getAbsolutePath()); } // create the writer writer = new OutputStreamWriter(new FileOutputStream(report), Charset.forName("UTF-8")); // use RMService to get disposition authority String dispositionAuthority = null; if (itemsToTransfer.length > 0) { // use the first transfer item to get to disposition schedule DispositionSchedule ds = dispositionService.getDispositionSchedule(itemsToTransfer[0]); if (ds != null) { dispositionAuthority = ds.getDispositionAuthority(); } } // write the HTML header writer.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"); writer.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n"); Boolean isAccession = (Boolean) this.nodeService.getProperty(transferNode, PROP_TRANSFER_ACCESSION_INDICATOR); if (isAccession) { writer.write("<title>Accession Report</title></head>\n"); } else { writer.write("<title>Transfer Report</title></head>\n"); } writer.write("<style>\n"); writer.write("body { font-family: arial,verdana; font-size: 81%; color: #333; }\n"); writer.write(".records { margin-left: 20px; margin-top: 10px; }\n"); writer.write(".record { padding: 5px; }\n"); writer.write(".label { color: #111; }\n"); writer.write(".nodeName { font-weight: bold; }\n"); writer.write(".transferred-item { background-color: #eee; padding: 10px; margin-bottom: 15px; }\n"); writer.write("</style>\n"); if (isAccession) { writer.write("<body>\n<h1>Accession Report</h1>\n"); } else { writer.write("<body>\n<h1>Transfer Report</h1>\n"); } writer.write("<table cellpadding=\"3\" cellspacing=\"3\">"); writer.write("<tr><td class=\"label\">Transfer Date:</td><td>"); Date transferDate = (Date) this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATED); writer.write(StringEscapeUtils.escapeHtml(transferDate.toString())); writer.write("</td></tr>"); writer.write("<tr><td class=\"label\">Transfer Location:</td><td>"); if (isAccession) { writer.write("NARA"); } else { writer.write(StringEscapeUtils.escapeHtml((String) this.nodeService.getProperty(transferNode, RecordsManagementModel.PROP_TRANSFER_LOCATION))); } writer.write("</td></tr>"); writer.write("<tr><td class=\"label\">Performed By:</td><td>"); writer.write(StringEscapeUtils .escapeHtml((String) this.nodeService.getProperty(transferNode, ContentModel.PROP_CREATOR))); writer.write("</td></tr>"); writer.write("<tr><td class=\"label\">Disposition Authority:</td><td>"); writer.write(dispositionAuthority != null ? StringEscapeUtils.escapeHtml(dispositionAuthority) : ""); writer.write("</td></tr></table>\n"); writer.write("<h2>Transferred Items</h2>\n"); // write out HTML representation of items to transfer generateTransferItemsHTML(writer, itemsToTransfer); // write the HTML footer writer.write("</body></html>"); } finally { if (writer != null) { try { writer.close(); } catch (IOException ioe) { } } } return report; }
From source file:heigit.ors.routing.RoutingProfilesUpdater.java
public void start() { // parse time of the format: day of the week, time, period String strDateTime = m_config.Time; String[] splitValues = strDateTime.split(","); int dayOfWeek = Integer.valueOf(splitValues[0].trim()) + 1; // Sunday is 1. m_updatePeriod = Integer.valueOf(splitValues[2].trim()); splitValues = splitValues[1].trim().split(":"); int hours = Integer.valueOf(splitValues[0].trim()); int minutes = Integer.valueOf(splitValues[1].trim()); int seconds = Integer.valueOf(splitValues[2].trim()); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK, dayOfWeek); calendar.set(Calendar.HOUR_OF_DAY, hours); calendar.set(Calendar.MINUTE, minutes); calendar.set(Calendar.SECOND, seconds); Date firstUpdateTime = calendar.getTime(); TimerTask timerTask = new UpdateTask(this); m_timer = new Timer(true); m_timer.schedule(timerTask, firstUpdateTime, m_updatePeriod); m_nextUpdate = firstUpdateTime;// w w w . j ava 2 s . co m LOGGER.info("Profile updater is started and scheduled at " + firstUpdateTime.toString() + "."); }
From source file:org.eclipsetrader.yahoojapan.internal.core.connector.BackfillConnector.java
@Override public ISplit[] backfillSplits(IFeedIdentifier identifier, Date from, Date to) { List<ISplit> list = new ArrayList<ISplit>(); System.out.println(from.toString()); System.out.println(to.toString()); Calendar c = Calendar.getInstance(); c.setTime(to);/* w w w .ja v a2s . co m*/ int lastYear = c.get(Calendar.YEAR); c.setTime(from); int firstYear = c.get(Calendar.YEAR); //limit 3 years if (firstYear < lastYear - 3) { firstYear = lastYear - 3; c.set(Calendar.YEAR, firstYear); } try { for (int page = 1; page < 21; page++) { HttpMethod method = Util.getDividendsHistoryMethod(identifier, to, c.getTime(), page); method.setFollowRedirects(true); HttpClient client = new HttpClient(); Util.setupProxy(client, method.getURI().getHost()); client.executeMethod(method); System.out.println(method.getURI().toString()); BufferedReader in = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream())); StringBuilder line = new StringBuilder(); // The first line is the header, ignoring String inputLine = in.readLine(); while ((inputLine = in.readLine()) != null) { // System.out.println("****" + inputLine); if (inputLine.indexOf("<!---->") >= 0) { break; } } while ((inputLine = in.readLine()) != null) { // System.out.println("+++" + inputLine); if (inputLine.indexOf("<!--/-->") >= 0) { String[] work = line.toString().split("</tr><tr><td>"); for (int i = 1; i < work.length; i++) { try { Split split = parseSplitsResponseLine(work[i]); if (split != null) { list.add(split); } } catch (ParseException e) { Status status = new Status(IStatus.ERROR, YahooJapanActivator.PLUGIN_ID, 0, "Error parsing data: " + work[i], e); YahooJapanActivator.log(status); } } break; } if (inputLine.startsWith("</tr><tr><td>")) { if (!inputLine.startsWith("</tr><tr><td>2")) { line = new StringBuilder(); } line.append(inputLine); } else if (inputLine.startsWith("</tr>")) { line.append(inputLine); } if (inputLine.startsWith("<td>")) { line.append(inputLine); } } boolean hasNextPage = false; if (inputLine.indexOf("<!---->") >= 0) { if (inputLine.indexOf("?") >= 0) { hasNextPage = true; } } else { while ((inputLine = in.readLine()) != null) { if (inputLine.indexOf("<!---->") >= 0) { if (inputLine.indexOf("?") >= 0) { hasNextPage = true; break; } } } } in.close(); if (!hasNextPage) { break; } } } catch (Exception e) { Status status = new Status(IStatus.ERROR, YahooJapanActivator.PLUGIN_ID, 0, "Error reading data", e); YahooJapanActivator.log(status); } return list.toArray(new ISplit[list.size()]); }
From source file:org.jbpm.instance.migration.Migrator.java
private String createMigrationMemo(int oldVersion, int newVersion, Date today, long predecessorProcessId) { StringBuffer buffer = new StringBuffer(); buffer.append("Process migrated from version ["); buffer.append(oldVersion);/*from w ww . jav a 2 s .co m*/ buffer.append("] to ["); buffer.append(newVersion); buffer.append("] on "); buffer.append(today.toString()); buffer.append(". Predecessor process instance id => "); buffer.append(predecessorProcessId); return buffer.toString(); }
From source file:com.zimbra.cs.index.LuceneViewer.java
private void dumpDocument(int docNum, Document doc) throws IOException { outputLn();//ww w. j av a 2 s .co m outputLn("Document " + docNum); if (doc == null) { outputLn(" deleted"); return; } // note: only stored fields will be returned for (Fieldable field : doc.getFields()) { String fieldName = field.name(); boolean isDate = "l.date".equals(fieldName); outputLn(" Field [" + fieldName + "]: " + field.toString()); String[] values = doc.getValues(fieldName); if (values != null) { int i = 0; for (String value : values) { output(" " + "(" + i++ + ") " + value); if (isDate) { try { Date date = DateTools.stringToDate(value); output(" (" + date.toString() + " (" + date.getTime() + "))"); } catch (java.text.ParseException e) { assert false; } } outputLn(); } } } }
From source file:Bean.LandingPageBean.java
private String getYearFromDate(Date execDate) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = null;//from w w w. j ava2s . c o m try { date = format.parse(execDate.toString()); } catch (ParseException e) { e.printStackTrace(); } SimpleDateFormat df = new SimpleDateFormat("yyyy"); String year = df.format(date); return year; }
From source file:com.nubits.nubot.tasks.SubmitLiquidityinfoTask.java
private String reportTier1() { String toReturn = ""; Global.orderManager.fetchOrders();/*from w ww. ja v a 2 s. c o m*/ ArrayList<Order> orderList = Global.orderManager.getOrderList(); if (SessionManager.sessionInterrupted()) return ""; //external interruption LOG.debug("Active orders : " + orderList.size()); Iterator<Order> it = orderList.iterator(); while (it.hasNext()) { Order o = it.next(); LOG.debug("order: " + o.getDigest()); } if (SessionManager.sessionInterrupted()) return ""; //external interruption if (verbose) { LOG.info(Global.exchange.getName() + "OLD NBTonbuy : " + Utils.formatNumber(Global.exchange.getLiveData().getNBTonbuy(), Settings.DEFAULT_PRECISION)); LOG.info(Global.exchange.getName() + "OLD NBTonsell : " + Utils.formatNumber(Global.exchange.getLiveData().getNBTonsell(), Settings.DEFAULT_PRECISION)); } double nbt_onsell = 0; double nbt_onbuy = 0; int sells = 0; int buys = 0; String digest = ""; for (int i = 0; i < orderList.size(); i++) { Order tempOrder = orderList.get(i); digest = digest + tempOrder.getDigest(); double toAdd = tempOrder.getAmount().getQuantity(); if (verbose) { LOG.info(tempOrder.toString()); } if (tempOrder.getType().equalsIgnoreCase(Constant.SELL)) { //Start summing up amounts of NBT nbt_onsell += toAdd; sells++; } else if (tempOrder.getType().equalsIgnoreCase(Constant.BUY)) { //Start summing up amounts of NBT nbt_onbuy += toAdd; buys++; } } //Update the order Global.exchange.getLiveData().setOrdersList(orderList); if (Global.conversion != 1 && Global.swappedPair) { //For swapped pair, need to convert the amounts to NBT nbt_onbuy = nbt_onbuy * Global.conversion; nbt_onsell = nbt_onsell * Global.conversion; } Global.exchange.getLiveData().setNBTonbuy(nbt_onbuy); Global.exchange.getLiveData().setNBTonsell(nbt_onsell); //Write to file timestamp,activeOrders, sells,buys, digest Date timeStamp = new Date(); String timeStampString = timeStamp.toString(); Long timeStampLong = Utils.getTimestampLong(); String toWrite = timeStampString + " , " + orderList.size() + " , " + sells + " , " + buys + " , " + digest; logOrderCSV(toWrite); if (SessionManager.sessionInterrupted()) return ""; //external interruption //Also update a json version of the output file //build the latest data into a JSONObject JSONObject latestOrders = new JSONObject(); latestOrders.put("time_stamp", timeStampLong); latestOrders.put("active_orders", orderList.size()); JSONArray jsonDigest = new JSONArray(); for (Iterator<Order> order = orderList.iterator(); order.hasNext();) { JSONObject thisOrder = new JSONObject(); Order _order = order.next(); //issue 160 - convert all amounts in NBT double amount = _order.getAmount().getQuantity(); //special case: swapped pair if (Global.conversion != 1) { if (Global.swappedPair)//For swapped pair, need to convert the amounts to NBT { amount = _order.getAmount().getQuantity() * Global.conversion; } } thisOrder.put("order_id", _order.getId()); thisOrder.put("time", _order.getInsertedDate().getTime()); thisOrder.put("order_type", _order.getType()); thisOrder.put("order_currency", _order.getPair().getOrderCurrency().getCode()); thisOrder.put("amount", amount); thisOrder.put("payment_currency", _order.getPair().getPaymentCurrency().getCode()); thisOrder.put("price", _order.getPrice().getQuantity()); jsonDigest.add(thisOrder); } latestOrders.put("digest", jsonDigest); if (SessionManager.sessionInterrupted()) return ""; //external interruption //now read the existing object if one exists JSONParser parser = new JSONParser(); JSONObject orderHistory = new JSONObject(); JSONArray orders = new JSONArray(); try { //object already exists in file orderHistory = (JSONObject) parser.parse(FilesystemUtils.readFromFile(this.jsonFile_orders)); orders = (JSONArray) orderHistory.get("orders"); } catch (ParseException pe) { LOG.error("Unable to parse " + this.jsonFile_orders); } //add the latest orders to the orders array orders.add(latestOrders); //then save logOrderJSON(orderHistory); if (verbose) { LOG.info(Global.exchange.getName() + "Updated NBTonbuy : " + Utils.formatNumber(nbt_onbuy, Settings.DEFAULT_PRECISION)); LOG.info(Global.exchange.getName() + "Updated NBTonsell : " + Utils.formatNumber(nbt_onsell, Settings.DEFAULT_PRECISION)); } if (SessionManager.sessionInterrupted()) return ""; //external interruption if (Global.options.isSubmitliquidity()) { //Call RPC double buySide; double sellSide; if (!Global.swappedPair) { buySide = Global.exchange.getLiveData().getNBTonbuy(); sellSide = Global.exchange.getLiveData().getNBTonsell(); } else { buySide = Global.exchange.getLiveData().getNBTonsell(); sellSide = Global.exchange.getLiveData().getNBTonbuy(); } toReturn = sendLiquidityInfoImpl(buySide, sellSide, 1); } return toReturn; }
From source file:com.linuxbox.enkive.workspace.searchQuery.SearchQuery.java
public void addAllSearchCriteria(String sender, String recipient, Date dateEarliest, Date dateLatest, String subject, String messageId, String content) { if (sender != null && !sender.isEmpty()) addCriterium(SENDER_PARAMETER, sender); if (recipient != null && !recipient.isEmpty()) addCriterium(RECIPIENT_PARAMETER, recipient); if (dateEarliest != null) addCriterium(DATE_EARLIEST_PARAMETER, dateEarliest.toString()); if (dateLatest != null) addCriterium(DATE_LATEST_PARAMETER, dateLatest.toString()); if (subject != null && !subject.isEmpty()) addCriterium(SUBJECT_PARAMETER, subject); if (messageId != null && !messageId.isEmpty()) addCriterium(MESSAGE_ID_PARAMETER, messageId); if (content != null && !content.isEmpty()) addCriterium(CONTENT_PARAMETER, content); }
From source file:org.activiti.bdd.ActivitiSpec.java
/** * Advances process engine by the specified amount of time. * // ww w .j a va 2 s .c o m * @param field * One of the field constants in java.util.Calendar. * @param amount * Amount to change field by. * @return The updated specification. * @see <a * href="https://docs.oracle.com/javase/6/docs/api/java/util/Calendar.html">java.util.Calendar</a> */ public ActivitiSpec whenProcessTimePassed(int field, int amount) { Calendar cal = activitiRule.getProcessEngine().getProcessEngineConfiguration().getClock() .getCurrentCalendar(); cal.add(field, amount); Date time = cal.getTime(); writeBddPhrase("WHEN: process time advanced to : %1$s", time.toString()); activitiRule.setCurrentTime(time); return this; }