List of usage examples for java.util Date getTime
public long getTime()
From source file:io.seldon.spark.actions.JobUtils.java
public static long dateToUnixDays(String dateString) throws ParseException { DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); Date date = dateFormat.parse(dateString); return ((date.getTime() / 1000) / 86400); }
From source file:de.kasoki.jfeedly.model.FeedlyConnection.java
private static Date getExpireDate(long expiresIn) { Date currentDate = new Date(); Date expireDate = new Date(currentDate.getTime() + (expiresIn * 1000)); return expireDate; }
From source file:com.epam.ta.reportportal.commons.Preconditions.java
public static Predicate<FinishExecutionRQ> finishSameTimeOrLater(final Date startTime) { return input -> input.getEndTime().getTime() >= startTime.getTime(); }
From source file:Main.java
/** * Tests if the specified <code>File</code> is older than the specified * <code>Date</code>./*from w w w. j a va2 s .c o m*/ * * @param file the <code>File</code> of which the modification date * must be compared, must not be {@code null} * @param date the date reference, must not be {@code null} * @return true if the <code>File</code> exists and has been modified * before the given <code>Date</code>. * @throws IllegalArgumentException if the file is {@code null} * @throws IllegalArgumentException if the date is {@code null} */ public static boolean isFileOlder(File file, Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileOlder(file, date.getTime()); }
From source file:Main.java
/** * Tests if the specified <code>File</code> is newer than the specified * <code>Date</code>./*w w w . ja v a 2 s . c o m*/ * * @param file the <code>File</code> of which the modification date * must be compared, must not be {@code null} * @param date the date reference, must not be {@code null} * @return true if the <code>File</code> exists and has been modified * after the given <code>Date</code>. * @throws IllegalArgumentException if the file is {@code null} * @throws IllegalArgumentException if the date is {@code null} */ public static boolean isFileNewer(File file, Date date) { if (date == null) { throw new IllegalArgumentException("No specified date"); } return isFileNewer(file, date.getTime()); }
From source file:Main.java
public static long stringDateToLong(String dateStr) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("GMT+8")); Date date = null; try {/*www . j av a2 s . c o m*/ date = sdf.parse(dateStr); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return date.getTime(); }
From source file:com.zimbra.examples.extns.samlprovider.SamlAuthProvider.java
private static Element getSamlAssertionRequest(String samlAssertionId) { Element envelope = new Element.XMLElement(new QName("Envelope", SoapProtocol.Soap11.getNamespace())); Element body = envelope.addElement(new QName("Body", SoapProtocol.Soap11.getNamespace())); Element requestElt = body.addElement(new QName("AssertionIDRequest", SAML_PROTOCOL_NS)); Date now = new Date(); requestElt.addAttribute("ID", "id-" + now.getTime()); requestElt.addAttribute("Version", "2.0"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); requestElt.addAttribute("IssueInstant", dateFormat.format(now)); Element idRefElt = requestElt.addElement(new QName("AssertionIDRef", SAML_PROTOCOL_NS)); idRefElt.addText(samlAssertionId);//from w w w.ja v a2 s .c o m return envelope; }
From source file:org.jutge.joc.porra.utils.AccountUtils.java
private static final boolean hasExpired(final Account account) { final Date accountCreatedOn = account.getCreatedOn(); final Date expiresOn = new Date(accountCreatedOn.getTime() + 21600000); // 6-7 hours i think return new Date().after(expiresOn); }
From source file:gemlite.core.common.DateUtil.java
/** * yyyyMMdd?long/*w w w .j a v a 2 s .co m*/ * @param dateStr * @return */ public static long toLong(String dateStr) { try { SimpleDateFormat YYYY_MM_DD = new SimpleDateFormat("yyyyMMdd"); Date dt = YYYY_MM_DD.parse(dateStr); return dt.getTime(); } catch (ParseException e) { LogUtil.getLogger().error("DateFormatUtil.toLong parser error:{}", dateStr); } return 0; }
From source file:com.alibaba.ims.platform.util.DateUtil.java
/** * ?/*w w w .j a va 2 s . c om*/ * * @param date * @return */ public static long minus(Date date) { if (date == null) { return Long.MAX_VALUE; } return ((date.getTime() - System.currentTimeMillis() - 1) / DateUtils.MILLIS_PER_DAY) + 1; }