List of usage examples for java.util Date getTime
public long getTime()
From source file:Main.java
public static long ISOtoEpoch(String time) { try {/*from w ww .ja v a 2s . c o m*/ Date d = ISO8601DATEFORMAT.parse(time); return d.getTime(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); return -2; } }
From source file:Main.java
/** * Converts into a "unix time", which means convert into the number of seconds * (NOT milliseconds) from the Epoch fit for the Facebook Query Language. * Notice that if you want data for September 15th then you need to present to * Facebook the NEXT DAY, ie. the upper exclusive limit of your date range. So * beyond all the sliding to midnight code you see in * {@link #convertToMidnightInPacificTimeZone(Date)}, we need to go further * and slide this input date forward one day. * /*from w w w . j a v a2 s . c om*/ * In retrospect, this should have been implemented via the Facebook * end_time_date() function. * * @param date * The date to convert. * @return Unix time representation of the given {@code date}. */ static long convertToUnixTimeOneDayLater(Date date) { long time = date.getTime() / 1000L; // note we cannot use a Daylight sensitive Calendar here since that would // adjust the time incorrectly over the DST junction time += SECONDS_IN_DAY; return time; }
From source file:Main.java
public static boolean isFileExpired(final File file, final long expiredTime) { Date date = new Date(); if (file.exists()) { return (date.getTime() - file.lastModified()) > expiredTime; }//from w w w . j ava 2s. com return false; }
From source file:Main.java
public static boolean isInFuture(int day, int month, int year) { Calendar c = Calendar.getInstance(); c.set(year, month - 1, day);// ww w .jav a 2s .com Date futureDate = c.getTime(); return (futureDate.getTime() > new Date().getTime()); }
From source file:Main.java
/** * * Return current date if not valid/*from www.j a va2s .c o m*/ */ public static long parseLongDate(long timestamp, long defaultValue) { Date d = new Date(timestamp); return d == null ? defaultValue : d.getTime(); }
From source file:Main.java
public static String formatRelativeDate(Context dateContext, Date date) { return DateUtils.getRelativeDateTimeString(dateContext, date.getTime(), DateUtils.MINUTE_IN_MILLIS, DateUtils.DAY_IN_MILLIS * 2, 0).toString(); }
From source file:Main.java
public static boolean isInPast(int day, int month, int year) { Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, year);/*from w ww . j av a 2 s .c om*/ c.set(Calendar.MONTH, month - 1); c.set(Calendar.DAY_OF_MONTH, day); Date pastDate = c.getTime(); return (pastDate.getTime() < new Date().getTime()); }
From source file:Main.java
/** * Invoke "search" action, triggering a default search. *//*from www .jav a 2s . c o m*/ public static long dateDiff(long timestamp) { Date now = new Date(); long diff = now.getTime() - timestamp; return diff; }
From source file:de.hybris.platform.accountsummaryaddon.utils.XDate.java
public static Date setToEndOfDay(final Date date) { Date newDate = new Date(date.getTime()); newDate = DateUtils.setHours(newDate, 23); newDate = DateUtils.setMinutes(newDate, 59); newDate = DateUtils.setSeconds(newDate, 59); newDate = DateUtils.setMilliseconds(newDate, 999); return newDate; }
From source file:Main.java
public static void checkValidityWithPublicKey(X509Certificate certificate, PublicKey publicKey) throws CertificateNotYetValidException, CertificateExpiredException { Date now = new Date(); long nowTime = now.getTime(); final int oneMinute = 60000; Date afterAddingOneMinute = new Date(nowTime + (5 * oneMinute)); //we are checking the certificate against current time plus five minutes to prevent false failure because of sync problems certificate.checkValidity(afterAddingOneMinute); if (!certificate.getPublicKey().equals(publicKey)) { throw new RuntimeException("Failed to validate public key"); }/*from w w w .ja va 2 s .c o m*/ }