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 String formatTime(Context context, Calendar date) {
    return DateUtils.formatDateTime(context, date.getTimeInMillis(), DateUtils.FORMAT_SHOW_TIME);
}

From source file:Main.java

public static String getTimestamp() {
    Calendar cal = Calendar.getInstance();
    long timestamp = cal.getTimeInMillis() / 1000;
    return String.valueOf(timestamp);
}

From source file:Main.java

public static String formatLongDate(Context context, Calendar date) {
    return DateUtils.formatDateTime(context, date.getTimeInMillis(), LONG_DATE);
}

From source file:Main.java

public static String getTimestamp() {
    Calendar cal = Calendar.getInstance();
    return Long.toString(cal.getTimeInMillis() / 1000);
}

From source file:Main.java

public static String getTimeLable(Context context, Calendar calendar) {
    return DateUtils.formatDateTime(context, calendar.getTimeInMillis(), DateUtils.FORMAT_SHOW_TIME);
}

From source file:Main.java

public static void setCurrentTime(boolean start) {
    Calendar calendar = Calendar.getInstance();
    long time = calendar.getTimeInMillis();

    if (start)/*from w w  w . j a v  a  2 s. com*/
        startTime = time;
    else
        endTime = time;
}

From source file:Main.java

public static void setToFirstDayInWeek(Calendar calendar) {
    calendar.set(Calendar.DAY_OF_WEEK, 1);
    calendar.getTimeInMillis();
}

From source file:Main.java

public static void setToFirstDayInMonth(Calendar calendar) {
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.getTimeInMillis();
}

From source file:Main.java

private static TimeDiff getDiff(final Calendar calOne, final Calendar calTwo) {
    return new TimeDiff(Math.abs(calOne.getTimeInMillis() - calTwo.getTimeInMillis()));
}

From source file:Main.java

/**
 * Returns the difference between two calendar objects in minutes.  A positive result means that the
 * actual time is later than the expected time
 * @param expectedTime The calendar object to compare against
 * @param actualTime The calendar object to compare
 * @return difference between the two calendar objects in minutes.  If the result is not on a minute boundary, the minute floor will be returned.
 *//*from  w w w .j  a va 2 s .  c o  m*/
public static int calculateTimeDifferenceInMinutes(Calendar expectedTime, Calendar actualTime) {
    long differenceInMillis = actualTime.getTimeInMillis() - expectedTime.getTimeInMillis();
    return (int) (differenceInMillis / (1000 * 60));
}