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:cn.powerdash.libsystem.common.security.authc.SessionTimeoutAuthenticationFilter.java
@Override protected void saveRequestAndRedirectToLogin(ServletRequest request, ServletResponse response) throws IOException { saveRequest(request);//ww w . j ava 2 s .co m HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; if (WebUtil.isAjaxRequest(req)) { ObjectMapper objectMapper = new ObjectMapper(); res.setContentType("application/json;charset=UTF-8"); res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); ResultDto<String> error = new ResultDto<String>(); error.setCode(ResultCode.SESSION_TIME_OUT); error.setMessage(MessageUtil.getMessage(SESSION_TIMEOUT_MSG)); objectMapper.writeValue(response.getWriter(), error); LOGGER.debug("session time out for ajax request:{}", req.getRequestURI()); } else { LOGGER.debug("session time out for request:{}", req.getRequestURI()); req.getSession().setAttribute(SESSION_TIMEOUT, true); redirectToLogin(request, response); } HttpSession session = req.getSession(false); if (session != null) { LOGGER.debug( "session time out with id: {}, is sesion new:{}, started: {}, last accessed: {}, request headers: {}", session.getId(), session.isNew(), DateFormatUtils.format(session.getCreationTime(), DATE_FORMAT), DateFormatUtils.format(session.getLastAccessedTime(), DATE_FORMAT), getHeaderString(request)); } else { LOGGER.debug("session time out, no session available for current request"); } }
From source file:cn.vlabs.umt.services.requests.impl.RequestMails.java
public void sendRegistUser(UserRequest request, UMTContext context) { Collection<User> admins = UMTContext.getAdminUsers(); if (admins == null || admins.size() == 0) { log.error("????"); return;//w ww. j a v a 2 s . c o m } Properties prop = new Properties(); setProperty(prop, "username", request.getUsername()); setProperty(prop, "truename", request.getTruename()); setProperty(prop, "orgnization", request.getOrgnization()); setProperty(prop, "phonenumber", request.getPhonenumber()); setProperty(prop, "createtime", DateFormatUtils.format(request.getCreateTime(), "yyyy-MM-dd")); setProperty(prop, "CurrentDate", DateFormatUtils.format(new Date(), "yyyy-MM-dd")); String to = ""; boolean first = true; for (User u : admins) { if (first) { to = u.getCstnetId(); first = false; } else { to = to + "," + u.getCstnetId(); } } try { sender.send(context.getLocale(), to, EmailTemplate.TARGET_REGISTER, prop); } catch (MailException e) { log.error(e.getMessage()); log.debug("information", e); } }
From source file:com.autonomy.aci.client.services.impl.ErrorProcessorTest.java
@Test public void testFullErrorResponseRawErrorId() throws XMLStreamException, AciErrorException, ProcessorException { try {//from w ww. ja v a 2 s . c o m // Execute the processor... processor.process(XmlTestUtils.getResourceAsXMLStreamReader( "/com/autonomy/aci/client/services/processor/errorProcessorTestFullErrorResponseRawErrorId.xml")); fail("Should have thrown an AciErrorException"); } catch (final AciErrorException exception) { // Check it... assertThat("errorId property not as expected.", exception.getErrorId(), is(equalTo("DAHGETQUERYTAGVALUES525"))); assertThat("rawErrorId property not as expected.", exception.getRawErrorId(), is(equalTo("0x20D"))); assertThat("errorString property not as expected.", exception.getErrorString(), is(equalTo("No valid parametric fields"))); assertThat("errorDescription property not as expected.", exception.getErrorDescription(), is(equalTo("The fieldname parameter contained no valid parametric fields"))); assertThat("errorCode property not as expected.", exception.getErrorCode(), is(equalTo("ERRORPARAMINVALID"))); assertThat("errorTime property not as expected.", DateFormatUtils.format(exception.getErrorTime(), "dd MMM yy HH:mm:ss"), is(equalTo("09 Jul 08 15:48:22"))); } }
From source file:gtu._work.ui.QuartzCronTestUI.java
private void initGUI() { try {//from w w w . j av a2s. c o m BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("CronExpression", null, jPanel1, null); { jPanel2 = new JPanel(); jPanel1.add(jPanel2, BorderLayout.NORTH); jPanel2.setPreferredSize(new java.awt.Dimension(439, 34)); { cronText = new JTextField(); jPanel2.add(cronText); cronText.setText(""); cronText.setPreferredSize(new java.awt.Dimension(229, 27)); } { executeBtn = new JButton(); jPanel2.add(executeBtn); executeBtn.setText("execute"); executeBtn.setPreferredSize(new java.awt.Dimension(85, 28)); executeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //XXX try { CronExpression cexp = new CronExpression(cronText.getText()); Date current = new Date(); setTitle(DateFormatUtils.format(current, "yyyy/MM/dd HH:mm:ss")); DefaultListModel cronListModel = new DefaultListModel(); for (int ii = 0, total = Integer .parseInt(limitText.getText()); ii < total; ii++) { current = cexp.getNextValidTimeAfter(current); if (current == null) { break; } cronListModel.addElement(ii + " : " + DateFormatUtils.format(current, "yyyy/MM/dd HH:mm:ss")); } cronList.setModel(cronListModel); } catch (Exception e) { e.printStackTrace(); JCommonUtil.handleException(e); return; } } }); } { limitText = new JTextField(); jPanel2.add(limitText); limitText.setText("2000"); limitText.setPreferredSize(new java.awt.Dimension(61, 24)); } } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(439, 253)); { DefaultListModel cronListModel = new DefaultListModel(); cronList = new JList(); jScrollPane1.setViewportView(cronList); cronList.setModel(cronListModel); } } } } pack(); this.setSize(460, 354); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:net.shopxx.plugin.unionpayPayment.UnionpayPaymentPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SystemUtils.getSetting(); PluginConfig pluginConfig = getPluginConfig(); PaymentLog paymentLog = getPaymentLog(sn); Map<String, String> parameterMap = new HashMap<String, String>(); parameterMap.put("txnType", "01"); parameterMap.put("channelType", "07"); parameterMap.put("currencyCode", CURRENCY); parameterMap.put("merId", pluginConfig.getAttribute("partner")); parameterMap.put("txnSubType", "01"); parameterMap.put("txnAmt", paymentLog.getAmount().multiply(new BigDecimal(100)).setScale(0).toString()); parameterMap.put("version", getVersion()); parameterMap.put("signMethod", "01"); parameterMap.put("bizType", "000201"); //B2Cwap parameterMap.put("encoding", getRequestCharset()); parameterMap.put("origQryId", ""); parameterMap.put("merAbbr", StringUtils.abbreviate(setting.getSiteName().replaceAll("[^0-9a-zA-Z\\u4e00-\\u9fa5 ]", ""), 40)); parameterMap.put("orderId", sn); parameterMap.put("txnTime", DateFormatUtils.format(new Date(), "yyyyMMddHHmmss")); parameterMap.put("accessType", "0"); //parameterMap.put("orderTimeout", "10080000"); parameterMap.put("frontUrl", getNotifyUrl(PaymentPlugin.NotifyMethod.sync)); parameterMap.put("backUrl", "http://wwww.specialurl.com/");//??? Map<String, String> submitStringData = AcpService.sign(parameterMap, getRequestCharset()); //certId,signaturesignData??????? Map<String, Object> submitObjectData = new HashMap<>(); for (String key : submitStringData.keySet()) { submitObjectData.put(key, submitStringData.get(key)); }/*from w w w . jav a 2 s .co m*/ return submitObjectData; }
From source file:net.shopxx.plugin.abcPayment.AbcPaymentPlugin.java
@Override public Map<String, Object> getParameterMap(String sn, String description, HttpServletRequest request) { Setting setting = SystemUtils.getSetting(); PluginConfig pluginConfig = getPluginConfig(); PaymentLog paymentLog = getPaymentLog(sn); Document document = DocumentHelper.createDocument(); Element msg = document.addElement("MSG"); Element message = msg.addElement("Message"); Element merchant = message.addElement("Merchant"); merchant.addElement("ECMerchantType").setText("B2C"); merchant.addElement("MerchantID").setText(pluginConfig.getAttribute("merchantId")); Element trxRequest = message.addElement("TrxRequest"); trxRequest.addElement("TrxType").setText("PayReq"); Element order = trxRequest.addElement("Order"); order.addElement("OrderNo").setText(sn); order.addElement("ExpiredDate").setText("7"); order.addElement("OrderAmount").setText(paymentLog.getAmount().setScale(2).toString()); order.addElement("OrderDesc").setText(StringUtils.abbreviate(description, 60)); order.addElement("OrderDate").setText(DateFormatUtils.format(new Date(), "yyyy/MM/dd")); order.addElement("OrderTime").setText(DateFormatUtils.format(new Date(), "HH:mm:ss")); order.addElement("OrderURL").setText(setting.getSiteUrl()); order.addElement("BuyIP").setText(request.getRemoteAddr()); order.addElement("OrderItems"); trxRequest.addElement("ProductType").setText("2"); trxRequest.addElement("PaymentType").setText("A"); trxRequest.addElement("NotifyType").setText("1"); trxRequest.addElement("ResultNotifyURL").setText(getNotifyUrl(PaymentPlugin.NotifyMethod.async)); trxRequest.addElement("MerchantRemarks").setText("shopxx"); trxRequest.addElement("PaymentLinkType").setText("1"); msg.addElement("Signature-Algorithm").setText("SHA1withRSA"); msg.addElement("Signature").setText(generateSign(merchant.asXML() + trxRequest.asXML())); Map<String, Object> parameterMap = new HashMap<String, Object>(); parameterMap.put("Signature", document.getRootElement().asXML()); parameterMap.put("errorPage", setting.getSiteUrl()); return parameterMap; }
From source file:com.sanyanyu.syybi.utils.DateUtils.java
/** * @Title:getDaysListBetweenDates/* w ww .ja v a 2 s . co m*/ * @Description: . * @param begin * . * @param end * ? . * @return * @return List<String> */ public static List<String> getDaysListBetweenDates(String begin, String end) { List<String> dateList = new ArrayList<String>(); Date d1; Date d2; d1 = DateUtils.parseDate(begin); d2 = DateUtils.parseDate(end); if (d1.compareTo(d2) > 0) { return dateList; } do { dateList.add(DateFormatUtils.format(d1, "yyyy-MM-dd")); d1 = DateUtils.addDays(d1, 1); } while (d1.compareTo(d2) <= 0); return dateList; }
From source file:cz.cuni.mff.ufal.dspace.app.xmlui.aspect.administrative.ControlPanelSignedLicenses.java
private Table create_table(Division div) throws WingException { String baseURL = contextPath + "/admin/epeople?"; // table//w w w . j av a 2 s.c om Table wftable = div.addTable("workspace_items", 1, 4, "table-condensed"); try { Row wfhead = wftable.addRow("", Row.ROLE_HEADER, "font_smaller"); // table items - because of GUI not all columns could be shown wfhead.addCellContent("ID"); wfhead.addCellContent("DATE"); wfhead.addCellContent("USERNAME"); wfhead.addCellContent("LICENSE"); wfhead.addCellContent("ITEM"); wfhead.addCellContent("BITSTREAM"); wfhead.addCellContent("EXTRA METADATA"); IFunctionalities functionalityManager = DSpaceApi.getFunctionalityManager(); functionalityManager.openSession(); java.util.List<LicenseResourceUserAllowance> licenses = functionalityManager.getSignedLicensesByDate(); // hack for group by ///////// /* we don't need group by now * List<String> keys = new ArrayList<String>(); List<LicenseResourceUserAllowance> licenses_group_by = new ArrayList<LicenseResourceUserAllowance>(); for (LicenseResourceUserAllowance license : licenses) { String createdOn = DateFormatUtils.format(license.getCreatedOn(), "ddMMyyyyhhmm"); String epersonID = "" + license.getUserRegistration().getEpersonId(); String licenseID = "" + license.getLicenseResourceMapping().getLicenseDefinition().getLicenseId(); String key = createdOn + ":" + epersonID + ":" + licenseID; if(!keys.contains(key)) { keys.add(key); licenses_group_by.add(license); } if(licenses_group_by.size()>=MAX_TO_SHOW) break; } */ ///////////////////////////// int cnt = 1; for (LicenseResourceUserAllowance license : licenses) { int bitstreamID = license.getLicenseResourceMapping().getBitstreamId(); LicenseDefinition ld = license.getLicenseResourceMapping().getLicenseDefinition(); UserRegistration ur = license.getUserRegistration(); Date signingDate = license.getCreatedOn(); Row r = wftable.addRow(null, null, "font_smaller bold"); String id = DateFormatUtils.format(signingDate, "yyyyMMddhhmmss") + "-" + ur.getEpersonId() + "-" + bitstreamID; r.addCellContent(id); r.addCellContent(DateFormatUtils.format(signingDate, "yyyy-MM-dd hh:mm:ss")); String eperson_id = String.format("%d [%s]", ur.getEpersonId(), ur.getEmail()); String url = baseURL + "submit_edit&epersonID=" + ur.getEpersonId(); r.addCell().addXref(url, eperson_id); r.addCell().addXref(ld.getDefinition(), ld.getName()); Bitstream bitstream = Bitstream.find(context, bitstreamID); Item item = (Item) bitstream.getParentObject(); String base = ConfigurationManager.getProperty("dspace.url"); StringBuffer itemLink = new StringBuffer().append(base).append(base.endsWith("/") ? "" : "/") .append("/handle/").append(item.getHandle()); r.addCell().addXref(itemLink.toString(), "" + item.getID()); StringBuffer bitstreamLink = new StringBuffer().append(base).append(base.endsWith("/") ? "" : "/") .append("bitstream/handle/").append(item.getHandle()).append("/") .append(URLEncoder.encode(bitstream.getName(), "UTF8")).append("?sequence=") .append(bitstream.getSequenceID()); r.addCell().addXref(bitstreamLink.toString(), "" + bitstream.getID()); Cell c = r.addCell(); List<UserMetadata> extraMetaData = functionalityManager.getUserMetadata_License(ur.getEpersonId(), license.getTransactionId()); for (UserMetadata metadata : extraMetaData) { c.addHighlight("label label-info font_smaller") .addContent(metadata.getMetadataKey() + ": " + metadata.getMetadataValue()); } if (++cnt > MAX_TO_SHOW) { break; } } functionalityManager.closeSession(); } catch (IllegalArgumentException e1) { wftable.setHead("No items - " + e1.getMessage()); } catch (Exception e2) { wftable.setHead("Exception - " + e2.toString()); } return wftable; }
From source file:com.haulmont.cuba.web.log.LogWindow.java
private String writeLog() { StringBuilder sb = new StringBuilder(); List<LogItem> items = App.getInstance().getAppLog().getItems(); for (LogItem item : items) { sb.append("<b>"); sb.append(DateFormatUtils.format(item.getTimestamp(), DATE_FORMAT)); sb.append(" "); sb.append(item.getLevel().name()); sb.append("</b> "); sb.append(StringEscapeUtils.escapeHtml(item.getMessage())); if (item.getStacktrace() != null) { sb.append(" "); String htmlMessage = StringEscapeUtils.escapeHtml(item.getStacktrace()); htmlMessage = StringUtils.replace(htmlMessage, "\n", "<br/>"); htmlMessage = StringUtils.replace(htmlMessage, " ", " "); htmlMessage = StringUtils.replace(htmlMessage, "\t", " "); sb.append(htmlMessage);//from ww w .j a va2 s. c o m } sb.append("<br/>"); } return sb.toString(); }
From source file:com.iflytek.kcloud.web.utils.BookDateUtil.java
/** * getDay:??. <br/>// w w w . j av a 2 s . c o m * * @param gap ?(0,1,-1....) * @return * @author zyyang3 * @since JDK 1.6 */ public static String getDay(int gap) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_MONTH, gap); Date date = cal.getTime(); String day = DateFormatUtils.format(date, "yyyy-MM-dd"); return day; }