List of usage examples for java.util Calendar MILLISECOND
int MILLISECOND
To view the source code for java.util Calendar MILLISECOND.
Click Source Link
get
and set
indicating the millisecond within the second. From source file:Main.java
public static long setTimeToMidnightAndGet(Calendar cal, long epoch) { cal.setTime(new Date(epoch)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/*ww w . ja v a 2 s . c o m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTimeInMillis(); }
From source file:Main.java
public static Date round2Hour(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/* w w w . j a v a2s . com*/ cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
From source file:Main.java
public static Calendar GetTodayLeftRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static Calendar getBeginOfDate(long time) { Calendar ret = Calendar.getInstance(); ret.setTimeInMillis(time);//from w w w. j a v a 2 s. c om ret.set(Calendar.HOUR_OF_DAY, 0); ret.set(Calendar.MINUTE, 0); ret.set(Calendar.SECOND, 0); ret.set(Calendar.MILLISECOND, 0); return ret; }
From source file:Main.java
public static Calendar getEndOfDate(long time) { Calendar ret = Calendar.getInstance(); ret.setTimeInMillis(time);//from w w w .j a v a 2 s .c o m ret.set(Calendar.HOUR_OF_DAY, 23); ret.set(Calendar.MINUTE, 59); ret.set(Calendar.SECOND, 59); ret.set(Calendar.MILLISECOND, 999); return ret; }
From source file:Main.java
public static long startOfTodDay() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); Date date = calendar.getTime(); return date.getTime(); }
From source file:Main.java
public static Calendar GetTodayRightRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static Calendar GetYesterdayLeftRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, -1); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static Calendar GetYesterdayRightRange(Calendar today) { Calendar calendar = (Calendar) today.clone(); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, -1); calendar.add(Calendar.MINUTE, 0); return calendar; }
From source file:Main.java
public static Date dayBegin(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);/*from w w w . j av a 2s.c om*/ c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); }