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.ipanel.apps.portalBackOffice.util.CommonsFiend.java
public static String[] getUpdateTime() { Date date = Calendar.getInstance().getTime(); date.setMinutes(date.getMinutes() + 1); String[] returnTime = new String[2]; returnTime[0] = DateFormatUtils.format(date, Defines.FORMAT_DATE_TIME_STRING); date.setHours(23);/* w w w. j a v a2 s .com*/ date.setMinutes(59); date.setSeconds(59); returnTime[1] = DateFormatUtils.format(date, Defines.FORMAT_DATE_TIME_STRING); return returnTime; }
From source file:com.sisrni.managedbean.DocumentacionProyectoMB.java
public void onProyectoChange() { try {/* w w w .j a v a 2 s .co m*/ Proyecto aux = null; if (docProySelected.getIdProyecto() != -1) { aux = proyectoService.getProyectoByID(docProySelected.getIdProyecto()); } searchDocumentoProyecto(docProySelected.getIdProyecto()); if (aux != null) { proyecto = aux; fechaInicio = DateFormatUtils.format(proyecto.getFechaInicio(), "dd/MM/yyyy"); fechaFin = DateFormatUtils.format(proyecto.getFechaFin(), "dd/MM/yyyy"); } else { proyecto = new Proyecto(); } } catch (Exception e) { } }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.header.HeaderPresenter.java
private void doHeaderUpdate(Node node) { try {// w w w . ja v a 2 s . com Calendar createdDate = node.hasProperty(JcrConstants.JCR_CREATED) ? node.getProperty(JcrConstants.JCR_CREATED).getDate() : null; String created = createdDate != null ? DateFormatUtils.format(createdDate, "MM/dd/yyyy, HH:mm:ss") : "unsaved"; Calendar lastModifiedDate = NodeTypes.LastModified.getLastModified(node); String lastModified = lastModifiedDate != null ? DateFormatUtils.format(lastModifiedDate, "MM/dd/yyyy, HH:mm:ss") : "unsaved"; String lastModifiedBy = NodeTypes.LastModified.getLastModifiedBy(node) != null ? NodeTypes.LastModified.getLastModifiedBy(node) : ""; String title = node.hasProperty("title") ? node.getProperty("title").getString() : "untitled"; HeaderInfo headerInfo = new HeaderInfo(StringEscapeUtils.escapeXml(title), lastModifiedBy, created, lastModified, lastModifiedBy, lastModifiedBy); headerView.update(headerInfo); } catch (RepositoryException e) { throw new RuntimeRepositoryException(e); } }
From source file:com.iflytek.kcloud.web.utils.BookDateUtil.java
/** * getDay:?. <br/>//w ww . j ava 2s . com * * @param gap (0,1,-1....) * @return * @throws ParseException * @author zyyang3 * @since JDK 1.6 */ public static String getDay(String time, int gap) throws ParseException { Calendar cal = Calendar.getInstance(); Date datetmp = sdf.parse(time); cal.setTime(datetmp); cal.add(Calendar.DAY_OF_MONTH, gap); Date date = cal.getTime(); String day = DateFormatUtils.format(date, "yyyy-MM-dd"); return day; }
From source file:com.sanyanyu.syybi.utils.DateUtils.java
/** * ?/*www .j a v a2 s . c o m*/ * @param begin * @param end * @return */ public static List<String> getMonthListBetweenDates(String begin, String end) { //? if (StringUtils.isNotBlank(begin) && begin.indexOf("-") > -1 && begin.length() == 7 && StringUtils.isNotBlank(end) && end.indexOf("-") > -1 && end.length() == 7) { List<String> monthList = new ArrayList<String>(); Date d1 = DateUtils.parseDate(begin + "-01"); Date d2 = DateUtils.parseDate(end + "-01"); if (d1.compareTo(d2) > 0) { return null; } do { monthList.add(DateFormatUtils.format(d1, "yyyy-MM")); d1 = DateUtils.addMonths(d1, 1); } while (d1.compareTo(d2) <= 0); return monthList; } return null; }
From source file:com.dbay.apns4j.tools.ApnsTools.java
public final static SocketFactory createSocketFactory(InputStream keyStore, String password, String keystoreType, String algorithm, String protocol) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException, KeyManagementException, CertificateExpiredException { char[] pwdChars = password.toCharArray(); KeyStore ks = KeyStore.getInstance(keystoreType); ks.load(keyStore, pwdChars);/*from w w w.j a v a2 s . co m*/ // ?? Enumeration<String> enums = ks.aliases(); String alias = ""; if (enums.hasMoreElements()) { alias = enums.nextElement(); } if (StringUtils.isNotEmpty(alias)) { X509Certificate certificate = (X509Certificate) ks.getCertificate(alias); if (null != certificate) { String type = certificate.getType(); int ver = certificate.getVersion(); String name = certificate.getSubjectDN().getName(); String serialNumber = certificate.getSerialNumber().toString(16); String issuerDN = certificate.getIssuerDN().getName(); String sigAlgName = certificate.getSigAlgName(); String publicAlgorithm = certificate.getPublicKey().getAlgorithm(); Date before = certificate.getNotBefore(); Date after = certificate.getNotAfter(); String beforeStr = DateFormatUtils.format(before, "yyyy-MM-dd HH:mm:ss"); String afterStr = DateFormatUtils.format(after, "yyyy-MM-dd HH:mm:ss"); // ?? long expire = DateUtil.getNumberOfDaysBetween(new Date(), after); if (expire <= 0) { if (LOG.isErrorEnabled()) { LOG.error( "?[{}], [{}], ?[{}], ??[{}], ?[{}], ??[{}], [{}], [{}][{}], ?[{}]", name, type, ver, serialNumber, issuerDN, sigAlgName, publicAlgorithm, beforeStr, afterStr, Math.abs(expire)); } throw new CertificateExpiredException("??[" + Math.abs(expire) + "]"); } if (LOG.isInfoEnabled()) { LOG.info( "?[{}], [{}], ?[{}], ??[{}], ?[{}], ??[{}], [{}], [{}][{}], ?[{}]?", name, type, ver, serialNumber, issuerDN, sigAlgName, publicAlgorithm, beforeStr, afterStr, expire); } } } KeyManagerFactory kf = KeyManagerFactory.getInstance(algorithm); kf.init(ks, pwdChars); TrustManagerFactory tmf = TrustManagerFactory.getInstance(algorithm); tmf.init((KeyStore) null); SSLContext context = SSLContext.getInstance(protocol); context.init(kf.getKeyManagers(), tmf.getTrustManagers(), null); return context.getSocketFactory(); }
From source file:jp.dip.komusubi.botter.Configuration.java
/** * //ww w. j a v a 2 s. c om * @param url * @param modified */ public void setLastModified(URL url, Date modified) { // ????????? if (getPropertyDate(url.toExternalForm()).after(modified)) { logger.warn( "???????????????: " + "property: {}, modified: {}", getPropertyDate(url.toExternalForm()), modified); return; } setLastModified(url, DateFormatUtils.format(modified, getDateFormatPattern()[0])); }
From source file:jp.canetrash.maven.plugin.bijint.BujintMojo.java
/** * http://www.bijint.com/ ?????URL??//from ww w. ja v a 2s . c o m * * @return ??URL */ String nowTimeImageUrl() throws Exception { String time = DateFormatUtils.format(new Date(), "hhmm"); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = buildDefaultHttpMessage(new HttpGet("http://www.bijint.com/cache/" + time + ".html")); httpget.setHeader("Referer", "http://www.bijint.com/jp/"); HttpResponse response = httpclient.execute(httpget); if (response.getStatusLine().getStatusCode() != 200) { getLog().error( "????????????????"); return null; } String result = IOUtils.toString(response.getEntity().getContent(), "UTF-8"); httpclient.getConnectionManager().shutdown(); return "http://www.bijint.com" + getImagePath(result); }
From source file:com.sanyanyu.syybi.utils.DateUtils.java
/** * @Title:getOffsetDate //from www . j a v a 2 s . co m * @Description: ????X * @param offset * @return * @return String */ public static String getOffsetDate(int offset) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_MONTH, offset); String currentDate = DateFormatUtils.format(cal, "yyyy-MM-dd"); return currentDate; }
From source file:info.magnolia.cms.gui.controlx.search.QueryBuilder.java
/** * Make a jcr expression out of the expression * @param param// w w w. ja v a 2 s. c o m * @return the expression as a string */ private String getDateJCRExpression(DateSearchQueryParameter param) { Date date = param.getValue(); if (param.getConstraint().equalsIgnoreCase(DateSearchQueryParameter.TODAY)) { date = new Date(); } StringBuffer buffer = new StringBuffer(); buffer.append(param.getName()); if (param.getConstraint().equalsIgnoreCase(DateSearchQueryParameter.BEFORE)) { buffer.append(" <= TIMESTAMP '"); } else if (param.getConstraint().equalsIgnoreCase(DateSearchQueryParameter.AFTER)) { buffer.append(" >= TIMESTAMP '"); } else if (param.getConstraint().equalsIgnoreCase(DateSearchQueryParameter.IS)) { buffer.append(" = TIMESTAMP '"); } buffer.append(DateFormatUtils.format(date, "yyyy-MM-dd")); buffer.append("T00:00:00.000Z'"); return buffer.toString(); }