Example usage for java.util Calendar MILLISECOND

List of usage examples for java.util Calendar MILLISECOND

Introduction

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

Prototype

int MILLISECOND

To view the source code for java.util Calendar MILLISECOND.

Click Source Link

Document

Field number for get and set indicating the millisecond within the second.

Usage

From source file:Main.java

public static long getTimesStart() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.SECOND, 0);//from w  w w.  j av a2  s .  c  om
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static long getSmallHourTimestamp() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR, 0);//from  ww w  .  j a v  a2s  .  c  om
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static long getTimesEnd() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 23);
    cal.set(Calendar.SECOND, 59);
    cal.set(Calendar.MINUTE, 59);
    cal.set(Calendar.MILLISECOND, 999);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static Calendar clearToDate(Calendar calendar) {
    return clear(calendar, Calendar.HOUR, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND,
            Calendar.MILLISECOND);
}

From source file:Main.java

private static long getTodayZeroTime() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.SECOND, 0);// ww  w.j a  va 2  s  .c o m
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static int getNumberOfWeeksInMonth(int year, int month) {
    Calendar calendar = Calendar.getInstance(Locale.FRANCE);
    calendar.set(year, month, 1, 0, 0, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    return calendar.getActualMaximum(Calendar.WEEK_OF_MONTH);
}

From source file:Main.java

public static void toBeginOfDay(Calendar cal) {
    cal.set(Calendar.HOUR_OF_DAY, 0); // ! clear would not reset the hour of day !
    cal.clear(Calendar.MINUTE);//  ww  w. ja va 2s. c o m
    cal.clear(Calendar.SECOND);
    cal.clear(Calendar.MILLISECOND);
}

From source file:Main.java

public static long getTimesNextStart() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 24);
    cal.set(Calendar.SECOND, 0);// ww w .  ja va 2 s  .  co  m
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static int getMillSec(Date date) {
    return getCalendar(date).get(Calendar.MILLISECOND);
}

From source file:Main.java

private static long getYesterdayZeroTime() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, -24);
    cal.set(Calendar.SECOND, 0);//w  w  w.ja  v  a 2 s .c  om
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}