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:com.makkajai.ObjCToCpp.java

private static double getDelta(Date startTime, Date stopTime) {
    return (stopTime.getTime() - startTime.getTime()) / 1000.0d;
}

From source file:Main.java

public static String getTitle() {

    Date date = new Date();

    String monthname = (String) android.text.format.DateFormat.format("MMMM yyyy", date.getTime());

    return monthname;
}

From source file:apm.common.utils.DateUtils.java

/**
 * ?//from w  ww.j a  v a 2s . c o m
 * @param date
 * @return
 */
public static long pastDays(Date date) {
    long t = new Date().getTime() - date.getTime();
    return t / (24 * 60 * 60 * 1000);
}

From source file:com.mycompany.app.VariousTest.java

public static int minutesDiff(Date earlierDate, Date laterDate) {
    if (earlierDate == null || laterDate == null)
        return 0;

    return (int) ((laterDate.getTime() / 60000) - (earlierDate.getTime() / 60000));
}

From source file:com.architexa.rse.DateUtil.java

public static boolean isExpired(String genPassword) {
    Date expireDate = getLicenseValidity(genPassword);
    if (now().getTime() > expireDate.getTime())
        return true;
    return false;
}

From source file:Main.java

public static Date addMinutes(Date aDate, double minutes) {
    long millesecondsToAdd = (long) (60 * 1000 * minutes);
    return new Date(aDate.getTime() + millesecondsToAdd);
}

From source file:Main.java

public static String getRelativeTimeDiff(Date date) {
    String timeDiff = DateUtils//from www . j  av  a  2 s . c  o  m
            .getRelativeTimeSpanString(date.getTime(), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS)
            .toString();

    if (timeDiff.contains("0 ")) {
        timeDiff = "in few seconds ago";
    }

    return timeDiff;
}

From source file:Main.java

public static boolean isTomorrow(Date date) {
    boolean isTomorrow = false;

    Date currentDate = new Date();
    Date firstTimeToday = firstTimeOfDate(currentDate);
    long firstSecondInLong = firstTimeToday.getTime() / 1000;

    long firstOfTomorrowDate = firstSecondInLong + 24 * 60 * 60;
    long lastOfTomorrowDate = firstOfTomorrowDate + 24 * 60 * 60;

    long secondOfDate = date.getTime() / 1000;
    if (secondOfDate >= firstOfTomorrowDate && secondOfDate <= lastOfTomorrowDate) {
        isTomorrow = true;//  w w w .j  a va  2  s .  com
    }

    return isTomorrow;
}

From source file:Main.java

public static boolean isOutCurrentTime(String endTime, String format) {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
    try {//from   w  w w  .j  a  v  a  2s  .  c o  m
        Date endDate = simpleDateFormat.parse(endTime);
        long endTimeLong = endDate.getTime();

        Date currDate = new Date(System.currentTimeMillis());
        String currTime = simpleDateFormat.format(currDate);
        currDate = simpleDateFormat.parse(currTime);
        long currentTime = currDate.getTime();

        return currentTime > endTimeLong;
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:Main.java

/**
 * //from  ww w . j  a  v a2  s  .  co m
 * @param d1
 * @param d2
 * @return
 */
public static String getDateDifference(Date d1, Date d2) {
    String unit = "seconds";
    long diff = d2.getTime() - d1.getTime();
    diff = diff / 1000;

    // /* More than 7 days? Then go to weeks */
    // if (diff >= (60 * 60 * 24 * 7)) {
    // diff = diff / 7;
    // unit = "weeks";
    // }

    /* More than 72 hours? Then go to days */
    if (diff >= (60 * 60 * 24 * 3)) {
        diff = diff / 24;
        unit = "days";
    }

    /* More than 60 minutes? Then go to hours */
    if (diff >= (60 * 60) && diff < (60 * 60 * 24 * 3)) {
        diff = diff / 60;
        unit = "hours";
    }

    /* More than 60 seconds? Then go to minutes */
    if (diff >= 60 && diff < (60 * 60)) {
        diff = diff / 60;
        unit = "minutes";
    }

    return diff + " " + unit;
}