List of usage examples for org.apache.commons.lang.time DateFormatUtils format
public static String format(Date date, String pattern)
Formats a date/time into a specific pattern.
From source file:org.xmlactions.web.conceal.CreateHandyParams.java
private void addDateTime() { String formatter = execContext.getString(FORMATTER_DATE_TIME); if (StringUtils.isEmpty(formatter)) { formatter = XSD_DATE_TIME_FMT;/* w w w .j a va 2 s . com*/ } Date date = new Date(System.currentTimeMillis()); String t = DateFormatUtils.format(date, formatter); execContext.put(CURRENT_DATE_TIME, t); }
From source file:org.xmlactions.web.conceal.CreateHandyParams.java
private void addLongTime() { String formatter = execContext.getString(FORMATTER_LONG_TIME); if (StringUtils.isEmpty(formatter)) { formatter = XSD_LONG_TIME_FMT;/*www . j a va 2 s. co m*/ } Date date = new Date(System.currentTimeMillis()); String t = DateFormatUtils.format(date, formatter); execContext.put(CURRENT_LONG_TIME, t); }
From source file:oscar.oscarReport.data.RptReportCreator.java
public static String getDiffDateFormat(String strDate, String oDate, String nDate) throws Exception { String ret = strDate;/* w w w. jav a 2s .c om*/ if (strDate.length() >= oDate.length()) { Date a = (new SimpleDateFormat(oDate)).parse(strDate); ret = DateFormatUtils.format(a, nDate); //ret = DateFormatUtils.format(DateUtils.parseDate(strDate, new String[] { oDate }), // nDate); } else { MiscUtils.getLogger().debug(" getDate wrong!!!"); } return ret; }
From source file:ubic.gemma.analysis.report.ArrayDesignReportServiceImpl.java
@Override public void generateAllArrayDesignReport() { log.info("Generating report summarizing all platforms ... "); // obtain time information (for timestamping) Date d = new Date(System.currentTimeMillis()); String timestamp = DateFormatUtils.format(d, "yyyy.MM.dd HH:mm"); long numCsBioSequences = arrayDesignService.numAllCompositeSequenceWithBioSequences(); long numCsBlatResults = arrayDesignService.numAllCompositeSequenceWithBlatResults(); long numCsGenes = arrayDesignService.numAllCompositeSequenceWithGenes(); long numGenes = arrayDesignService.numAllGenes(); // create a surrogate ArrayDesignValue object to represent the total of all platforms ArrayDesignValueObject adVo = new ArrayDesignValueObject(); adVo.setNumProbeSequences(Long.toString(numCsBioSequences)); adVo.setNumProbeAlignments(Long.toString(numCsBlatResults)); adVo.setNumProbesToGenes(Long.toString(numCsGenes)); adVo.setNumGenes(Long.toString(numGenes)); adVo.setDateCached(timestamp);//from w w w.j a va 2s . c om try { // remove file first File f = new File(HOME_DIR + File.separatorChar + ARRAY_DESIGN_REPORT_DIR + File.separatorChar + ARRAY_DESIGN_SUMMARY); if (f.exists()) { if (!f.canWrite() || !f.delete()) { log.warn("Cannot write to file."); return; } } FileOutputStream fos = new FileOutputStream(HOME_DIR + File.separatorChar + ARRAY_DESIGN_REPORT_DIR + File.separatorChar + ARRAY_DESIGN_SUMMARY); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(adVo); oos.flush(); oos.close(); } catch (Throwable e) { // cannot write to file. Just fail gracefully. log.error("Cannot write to file."); } log.info("Done making reports"); }
From source file:ubic.gemma.analysis.report.ArrayDesignReportServiceImpl.java
@Override public void generateArrayDesignReport(ArrayDesignValueObject adVo) { ArrayDesign ad = arrayDesignService.load(adVo.getId()); if (ad == null) return;/* w w w . j a v a 2s.c om*/ // obtain time information (for timestamping) Date d = new Date(System.currentTimeMillis()); String timestamp = DateFormatUtils.format(d, "yyyy.MM.dd HH:mm"); long numProbes = arrayDesignService.getCompositeSequenceCount(ad); long numCsBioSequences = arrayDesignService.numCompositeSequenceWithBioSequences(ad); long numCsBlatResults = arrayDesignService.numCompositeSequenceWithBlatResults(ad); long numCsGenes = arrayDesignService.numCompositeSequenceWithGenes(ad); long numGenes = arrayDesignService.numGenes(ad); adVo.setDesignElementCount(numProbes); adVo.setNumProbeSequences(Long.toString(numCsBioSequences)); adVo.setNumProbeAlignments(Long.toString(numCsBlatResults)); adVo.setNumProbesToGenes(Long.toString(numCsGenes)); adVo.setNumGenes(Long.toString(numGenes)); adVo.setDateCached(timestamp); // check the directory exists. String reportDir = HOME_DIR + File.separatorChar + ARRAY_DESIGN_REPORT_DIR; File reportDirF = new File(reportDir); if (!reportDirF.exists()) { reportDirF.mkdirs(); } String reportFileName = reportDir + File.separatorChar + ARRAY_DESIGN_REPORT_FILE_NAME_PREFIX + "." + adVo.getId(); try { // remove old file first (possible todo: don't do this until after new file is okayed - maybe this delete // isn't needed, just clobber.) File f = new File(reportFileName); if (f.exists()) { if (!f.canWrite() || !f.delete()) { log.error( "Report exists but cannot overwrite, leaving the old one in place: " + reportFileName); return; } } FileOutputStream fos = new FileOutputStream(reportFileName); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(adVo); oos.flush(); oos.close(); } catch (Throwable e) { log.error("Cannot write to file: " + reportFileName); return; } log.info("Generated report for " + ad); }
From source file:ubic.gemma.analysis.report.ArrayDesignReportServiceImpl.java
/** * FIXME this could be refactored and used elsewhere. This is similar to code in the AuditableService/Dao. * // www . j a v a 2 s . co m * @param id * @param eventType * @return */ private String getLastEvent(Long id, Class<? extends AuditEventType> eventType) { ArrayDesign ad = arrayDesignService.load(id); if (ad == null) return ""; List<AuditEvent> events2 = auditEventService.getEvents(ad); String analysisEventString = ""; List<AuditEvent> events = new ArrayList<AuditEvent>(); for (AuditEvent event : events2) { if (event == null) continue; // legacy of ordered-list which could end up with gaps; should not be needed // any more if (event.getEventType() != null && eventType.isAssignableFrom(event.getEventType().getClass())) { events.add(event); } } if (events.size() == 0) { return "[None]"; } // add the most recent events to the report. fixme check there are events. AuditEvent lastEvent = events.get(events.size() - 1); analysisEventString = DateFormatUtils.format(lastEvent.getDate(), "yyyy.MMM.dd hh:mm aa"); return analysisEventString; }
From source file:ubic.gemma.web.taglib.LastModifiedTag.java
@Override public int doStartTag() throws JspException { StringBuilder buf = new StringBuilder(); buf.append("<div> Last Modified : "); String ref = ""; ref = pageContext.getServletContext().getRealPath(refFile); File mainFile = new File(ref); Date d = new Date(mainFile.lastModified()); String dateString = DateFormatUtils.format(d, "yyyy.MM.dd hh:mm"); buf.append(dateString);// w w w. j a va 2 s .com buf.append("</div>"); try { pageContext.getOut().print(buf.toString()); } catch (Exception ex) { throw new JspException("lastModifiedTag: " + ex.getMessage()); } return SKIP_BODY; }
From source file:xmltype.XMLTypeTest.java
private ChargeType createCharge() throws ParseException { final ChargeType charge = new ChargeType(); charge.setSupplierBillID("19255500000000000079"); // ? TODO , ? (Bill.xsd) Date billDate = DateUtils.parseDate("2011-03-10", new String[] { "yyyy-MM-dd" }); charge.setBillDate(XmlTypes.date(DateFormatUtils.format(billDate, "dd.MM.yyyy"))); // ?? ? final Organization supplierOrgInfo = new Organization(); supplierOrgInfo.setName(/*from w w w .j a va 2 s . co m*/ " ? ? ?"); supplierOrgInfo.setINN("1655102196"); supplierOrgInfo.setKPP("165501001"); final Account account = new Account(); account.setAccount("40101810800000010001"); final Bank bank = new Bank(); bank.setBIK("049205001"); bank.setName(" ? . "); account.setBank(bank); supplierOrgInfo.setAccount(account); charge.setSupplierOrgInfo(supplierOrgInfo); charge.setBillFor("? ?"); charge.setTotalAmount(100000L); charge.setChangeStatus( "1"); /* ? ? 1 - 2 - 3 - */ charge.setTreasureBranch(" ? ?"); // , ? ? ?? charge.setKBK("19210806000011000110"); charge.setOKATO("92401000000"); final BudgetIndex budgetIndex = new BudgetIndex(); budgetIndex.setStatus("0"); //? //TODO ? budgetIndex ? ? ?? ??? ? ? ?? budgetIndex.setPaymentType("0"); // budgetIndex.setPurpose("0"); // ? 2 ? ? budgetIndex.setTaxPeriod("0"); // 10 ? budgetIndex.setTaxDocNumber("0"); // budgetIndex.setTaxDocDate("0"); // charge.setBudgetIndex(budgetIndex); charge.setApplicationID("455555"); //TODO , ? ?? ? 20 ? charge.setUnifiedPayerIdentifier("0100000000006667775555643"); // return charge; }