Example usage for java.util Date getTime

List of usage examples for java.util Date getTime

Introduction

In this page you can find the example usage for java.util Date getTime.

Prototype

public long getTime() 

Source Link

Document

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.

Usage

From source file:Main.java

public static long geCurrenttMillisecond() {
    Date date = new Date();
    return date.getTime();
}

From source file:Main.java

public static long generateUNIXTimestamp() {
    Date date = new Date();
    return (date.getTime() / 1000L);
}

From source file:Main.java

private static int diasEntreFechas(Date fechaInicial, Date fechaFinal) {
    return (int) ((fechaFinal.getTime() - fechaInicial.getTime()) / (1000 * 60 * 60 * 24));
}

From source file:Main.java

/**
 * @param date1 -past date/*from   ww w  . j a  v a2s  .c o  m*/
 * @param date2 -future date than date1
 * @return total days between Dates
 */
private static int getDaysBetweenDates(Date date1, Date date2) {
    return (int) ((date2.getTime() - date1.getTime()) / (1000 * 60 * 60 * 24L));
}

From source file:Main.java

public static boolean isToday(Date time) {
    return isToday(time.getTime());
}

From source file:Main.java

public static long getTimestamp() {
    Date date = new Date();

    return date.getTime();
}

From source file:Main.java

public static int getMinutesBetweenTwoDates(Date start, Date end) {
    long diff = Math.abs(end.getTime() - start.getTime());
    return (int) (diff / 1000 / 60);
}

From source file:Main.java

private static int getNow() {
    Date date = new Date();
    long t = date.getTime();
    return (int) (t / 1000);
}

From source file:Main.java

private static long getTimestamp() {
    Date date = new Date();
    long i = date.getTime();
    return i;//from  w ww  .  ja v a  2  s.  com
}

From source file:Main.java

public static Date sumDates(Date d1, Date d2) {
    return new Date(d1.getTime() + d2.getTime());
}