Example usage for java.util Calendar getTimeInMillis

List of usage examples for java.util Calendar getTimeInMillis

Introduction

In this page you can find the example usage for java.util Calendar getTimeInMillis.

Prototype

public long getTimeInMillis() 

Source Link

Document

Returns this Calendar's time value in milliseconds.

Usage

From source file:Main.java

public static int compareTo(Date remindAt, Calendar now) {
    if (remindAt.getTime() == now.getTimeInMillis())
        return 0;
    return remindAt.getTime() - now.getTimeInMillis() < 0 ? -1 : 1;
}

From source file:Main.java

public static long now() {
    Calendar cal = Calendar.getInstance();
    return cal.getTimeInMillis();
}

From source file:Main.java

/**
 * Get Date from Calendar//w w w.  j  a  v a 2 s.  c o  m
 * @param cal Calendar
 * @return Date generated
 */
public static Date generateDate(Calendar cal) {
    return new Date(cal.getTimeInMillis());
}

From source file:Main.java

public static long spanTotalHours(Calendar calendar1, Calendar calendar2) {
    return (calendar1.getTimeInMillis() - calendar2.getTimeInMillis()) / 1000 / 60 / 60;
}

From source file:Main.java

public static long getLocalTime() {
    Calendar cal = Calendar.getInstance();
    return cal.getTimeInMillis();
}

From source file:Main.java

public static long spanTotalDays(Calendar calendar1, Calendar calendar2) {
    return (calendar1.getTimeInMillis() - calendar2.getTimeInMillis()) / 1000 / 60 / 60 / 24;
}

From source file:Main.java

public static int daysSince(final Calendar date) {
    return daysSince(date.getTimeInMillis());
}

From source file:Main.java

public static long getIntervalInSeconds(Calendar calendar, Calendar targetCalendar) {
    return (calendar.getTimeInMillis() - targetCalendar.getTimeInMillis()) / 1000;
}

From source file:Main.java

public static int timeSpanInDays(Calendar cal1, Calendar cal2) {
    return (int) ((Math.abs(cal1.getTimeInMillis() - cal2.getTimeInMillis())) / (1000 * 60 * 60 * 24));
}

From source file:Main.java

public static long getDateDiff(Calendar cal1, Calendar cal2) {
    long cal1Day = cal1.getTimeInMillis() / 1000 / (60 * 60 * 24);
    long cal2Day = cal2.getTimeInMillis() / 1000 / (60 * 60 * 24);

    long diffDay = cal1Day - cal2Day;

    return diffDay;
}