List of usage examples for org.apache.commons.lang.time DateFormatUtils ISO_DATE_FORMAT
FastDateFormat ISO_DATE_FORMAT
To view the source code for org.apache.commons.lang.time DateFormatUtils ISO_DATE_FORMAT.
Click Source Link
From source file:com.vmware.thinapp.common.util.AfUtil.java
/** * Parse ISO date format date string to java.util.Date. * * @param dateStr a date string in yyyy-MM-dd format * @return an instance of java.util.Date if parsing was successful; otherwise, return null. *///from ww w. j a v a2s . co m public static Date parseIsoDate(String dateStr) { String pattern = DateFormatUtils.ISO_DATE_FORMAT.getPattern(); Date date = null; try { date = DateUtils.parseDate(dateStr, new String[] { pattern }); } catch (ParseException e) { /* Eat the exception */ } return date; }
From source file:javacommon.excel.ExcelReader.java
/** * ???// w w w. j ava2 s . c om * * @param c ? * @return */ private String getCellStringValue(Cell c) { if (c == null) { return ""; } String value = null; NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(false); nf.setMaximumFractionDigits(12); switch (c.getCellType()) { case Cell.CELL_TYPE_BOOLEAN: value = String.valueOf(c.getBooleanCellValue()); break; case Cell.CELL_TYPE_NUMERIC: if (DateUtil.isCellDateFormatted(c)) { return DateFormatUtils.ISO_DATE_FORMAT.format(c.getDateCellValue()); } else if ("@".equals(c.getCellStyle().getDataFormatString())) { value = nf.format(c.getNumericCellValue()); } else if ("General".equals(c.getCellStyle().getDataFormatString())) { value = nf.format(c.getNumericCellValue()); } else if (ArrayUtils.contains(ExcelConstants.DATE_PATTERNS, c.getCellStyle().getDataFormatString())) { value = DateFormatUtils.format(HSSFDateUtil.getJavaDate(c.getNumericCellValue()), c.getCellStyle().getDataFormatString()); } else { value = nf.format(c.getNumericCellValue()); } break; case Cell.CELL_TYPE_STRING: value = c.getStringCellValue(); break; case Cell.CELL_TYPE_FORMULA: value = c.getCellFormula(); break; } return value == null ? "" : value.trim(); }
From source file:javacommon.excel.ExcelReader.java
/** * ???/* w w w. j av a 2 s . c o m*/ * * @param c ? * @return */ private String getCellStringFormatValue(Cell c) { if (c == null) { return ""; } String value = null; NumberFormat nf = NumberFormat.getInstance(); nf.setGroupingUsed(false); nf.setMaximumFractionDigits(12); switch (c.getCellType()) { case Cell.CELL_TYPE_BOOLEAN: value = String.valueOf(c.getBooleanCellValue()); break; case Cell.CELL_TYPE_NUMERIC: if (DateUtil.isCellDateFormatted(c)) { return DateFormatUtils.ISO_DATE_FORMAT.format(c.getDateCellValue()); } else if ("@".equals(c.getCellStyle().getDataFormatString())) { value = nf.format(c.getNumericCellValue()); } else if ("General".equals(c.getCellStyle().getDataFormatString())) { value = nf.format(c.getNumericCellValue()); } else if (ArrayUtils.contains(ExcelConstants.DATE_PATTERNS, c.getCellStyle().getDataFormatString())) { value = DateFormatUtils.format(HSSFDateUtil.getJavaDate(c.getNumericCellValue()), c.getCellStyle().getDataFormatString()); } else { value = nf.format(c.getNumericCellValue()); } break; case Cell.CELL_TYPE_STRING: value = c.getStringCellValue(); break; case Cell.CELL_TYPE_FORMULA: return c.getCellFormula(); } return value == null ? "" : value.trim(); }
From source file:com.ikanow.aleph2.v1.document_db.utils.LegacyV1HadoopUtils.java
/** C/P from v1 QueryHandler.getInterval * @param sDate//w w w. ja v a 2 s. c o m * @return */ private static long parseDate(String sDate) { if (null == _allowedDatesArray) { _allowedDatesArray = new String[] { "yyyy'-'DDD", "yyyy'-'MM'-'dd", "yyyyMMdd", "dd MMM yyyy", "dd MMM yy", "MM/dd/yy", "MM/dd/yyyy", "MM.dd.yy", "MM.dd.yyyy", "yyyy'-'MM'-'dd hh:mm:ss", "dd MMM yy hh:mm:ss", "dd MMM yyyy hh:mm:ss", "MM/dd/yy hh:mm:ss", "MM/dd/yyyy hh:mm:ss", "MM.dd.yy hh:mm:ss", "MM.dd.yyyy hh:mm:ss", DateFormatUtils.ISO_DATE_FORMAT.getPattern(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), DateFormatUtils.ISO_DATE_TIME_ZONE_FORMAT.getPattern(), DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern(), DateFormatUtils.SMTP_DATETIME_FORMAT.getPattern() }; } try { Date date = DateUtils.parseDate(sDate, _allowedDatesArray); return date.getTime(); } catch (Exception e) { // Error all the way out throw new RuntimeException(e); } }
From source file:com.ikanow.infinit.e.api.knowledge.QueryHandler.java
private static long parseDate(String sDate) { if (null == _allowedDatesArray) { _allowedDatesArray = new String[] { "yyyy'-'DDD", "yyyy'-'MM'-'dd", "yyyyMMdd", "dd MMM yyyy", "dd MMM yy", "MM/dd/yy", "MM/dd/yyyy", "MM.dd.yy", "MM.dd.yyyy", "yyyy'-'MM'-'dd hh:mm:ss", "dd MMM yy hh:mm:ss", "dd MMM yyyy hh:mm:ss", "MM/dd/yy hh:mm:ss", "MM/dd/yyyy hh:mm:ss", "MM.dd.yy hh:mm:ss", "MM.dd.yyyy hh:mm:ss", DateFormatUtils.ISO_DATE_FORMAT.getPattern(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), DateFormatUtils.ISO_DATE_TIME_ZONE_FORMAT.getPattern(), DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern(), DateFormatUtils.SMTP_DATETIME_FORMAT.getPattern() }; }// ww w. j a v a 2s .c o m try { Date date = DateUtils.parseDate(sDate, _allowedDatesArray); return date.getTime(); } catch (Exception e) { // Error all the way out throw new RuntimeException(e); } }
From source file:org.apache.directory.studio.connection.ui.widgets.CertificateInfoComposite.java
/** * Sets the input for this composite. //www. ja v a 2 s .c o m * * @param certificateChain certificate chain input */ public void setInput(X509Certificate[] certificateChain) { X509Certificate certificate = certificateChain[0]; X500Principal issuedToPrincipal = certificate.getSubjectX500Principal(); Map<String, String> issuedToAttributes = getAttributeMap(issuedToPrincipal); issuedToCN.setText(issuedToAttributes.get("CN")); //$NON-NLS-1$ issuedToO.setText(issuedToAttributes.get("O")); //$NON-NLS-1$ issuedToOU.setText(issuedToAttributes.get("OU")); //$NON-NLS-1$ serialNumber.setText(certificate.getSerialNumber().toString(16)); X500Principal issuedFromPrincipal = certificate.getIssuerX500Principal(); Map<String, String> issuedFromAttributes = getAttributeMap(issuedFromPrincipal); issuedByCN.setText(issuedFromAttributes.get("CN")); //$NON-NLS-1$ issuedByO.setText(issuedFromAttributes.get("O")); //$NON-NLS-1$ issuedByOU.setText(issuedFromAttributes.get("OU")); //$NON-NLS-1$ issuesOn.setText(DateFormatUtils.ISO_DATE_FORMAT.format(certificate.getNotBefore())); expiresOn.setText(DateFormatUtils.ISO_DATE_FORMAT.format(certificate.getNotAfter())); byte[] encoded2 = null; try { encoded2 = certificate.getEncoded(); } catch (CertificateEncodingException e) { } byte[] md5 = DigestUtils.md5(encoded2); String md5HexString = getHexString(md5); fingerprintMD5.setText(md5HexString); byte[] sha = DigestUtils.sha(encoded2); String shaHexString = getHexString(sha); fingerprintSHA1.setText(shaHexString); // Details: certificate chain CertificateChainItem parentItem = null; CertificateChainItem certificateItem = null; for (X509Certificate cert : certificateChain) { CertificateChainItem item = new CertificateChainItem(cert); if (parentItem != null) { item.child = parentItem; parentItem.parent = item; } if (certificateItem == null) { certificateItem = item; } parentItem = item; } hierarchyTreeViewer.setInput(new CertificateChainItem[] { parentItem }); hierarchyTreeViewer.expandAll(); hierarchyTreeViewer.setSelection(new StructuredSelection(certificateItem), true); // Details: certificateTree.removeAll(); populateCertificateTree(); valueText.setText(StringUtils.EMPTY); }
From source file:org.eclipse.gyrex.p2.internal.installer.InstallLog.java
/** * Creates a new instance./*from www. j a v a2s. c om*/ * * @param shaHex * @throws IOException */ public InstallLog(final String sessionId) throws IOException { this.sessionId = sessionId; creationDate = new Date(); final IPath logsFolder = PackageInstallState.getBaseLocation().append("logs"); final String baseName = "install-" + DateFormatUtils.ISO_DATE_FORMAT.format(creationDate); // create new log file final File logFile = createNewLog(logsFolder, baseName); if (null == logFile) { throw new IllegalStateException("unable to create new log file; file count limit exceeded"); } this.logFile = logFile; logFileWriter = new PrintWriter(new FileWriterWithEncoding(logFile, CharEncoding.UTF_16)); // write header writeHeader(); }
From source file:org.eclipse.skalli.model.EntityBaseTest.java
@Test(expected = IllegalArgumentException.class) public void testInvalidLastModified() { long now = System.currentTimeMillis(); TestEntityBase entity = new TestEntityBase(); entity.setLastModified(DateFormatUtils.ISO_DATE_FORMAT.format(now)); entity.setLastModified(DateFormatUtils.ISO_DATE_TIME_ZONE_FORMAT.format(now)); entity.setLastModified(DateFormatUtils.ISO_TIME_FORMAT.format(now)); entity.setLastModified("foobar"); entity.setLastModified(Long.toString(now)); }
From source file:org.gbif.registry.ws.util.DataCiteConverter.java
private static String fdate(Date date) { return DateFormatUtils.ISO_DATE_FORMAT.format(date); }
From source file:org.mailster.MailsterSWT.java
public void versionCheck() { (new Thread() { public void run() { try { InputStream in = (new URL(ConfigurationManager.MAILSTER_VERSION_CHECK_URL)).openStream(); byte[] buf = new byte[64]; int len = 0; int offset = 0; while ((len = in.read(buf, offset, 64 - offset)) != -1) { offset += len;/* w ww . j a va2 s . c o m*/ } in.close(); String line = new String(buf, 0, offset); int pos = line.indexOf(' '); String ver = line.substring(0, pos); String currentVer = ConfigurationManager.MAILSTER_VERSION_NB.substring(1); boolean updateNeeded = true; if (currentVer.charAt(0) > ver.charAt(0)) updateNeeded = false; else if (currentVer.charAt(2) > ver.charAt(2)) updateNeeded = false; else if (currentVer.charAt(4) > ver.charAt(4)) updateNeeded = false; String msg = null; if (updateNeeded) { Date d = new Date(Long.parseLong(line.substring(pos + 1))); StringBuilder sb = new StringBuilder( Messages.getString("MailView.tray.versioncheck.needUpdate")); //$NON-NLS-1$ sb.append('\n'); sb.append(MessageFormat.format(Messages.getString("MailView.tray.versioncheck.available"), //$NON-NLS-1$ ver, DateFormatUtils.ISO_DATE_FORMAT.format(d))); msg = sb.toString(); } else msg = Messages.getString("MailView.tray.versioncheck.upToDate"); //$NON-NLS-1$ showTrayItemTooltipMessage(Messages.getString("MailView.tray.versioncheck.title") //$NON-NLS-1$ + DateUtilities.format(DateFormatterEnum.HOUR, new Date()) + ")", //$NON-NLS-1$ msg); if (updateNeeded) Display.getDefault().asyncExec(new Thread() { public void run() { multiView.showURL(ConfigurationManager.MAILSTER_DOWNLOAD_PAGE, false, true); } }); } catch (Exception ex) { LOG.debug("Failed to check if version is up to date", ex); //$NON-NLS-1$ log("Failed to check if version is up to date"); //$NON-NLS-1$ } } }).start(); }