List of usage examples for java.util Calendar HOUR_OF_DAY
int HOUR_OF_DAY
To view the source code for java.util Calendar HOUR_OF_DAY.
Click Source Link
get
and set
indicating the hour of the day. 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 long firstOfTheMonth9am() { Calendar c = Calendar.getInstance(); c.set(Calendar.DAY_OF_MONTH, 1); c.set(Calendar.HOUR_OF_DAY, 9); c.set(Calendar.MINUTE, 0);/* w w w . j av a 2 s . c o m*/ c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTimeInMillis(); }
From source file:Main.java
public static Calendar getCalendarAtMidnight(int relativeDayToToday) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.add(Calendar.DAY_OF_YEAR, relativeDayToToday); return calendar; }
From source file:Main.java
public static long getTimesmorning() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.SECOND, 0);//w w w . j ava 2 s .co m cal.set(Calendar.MINUTE, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTimeInMillis(); }
From source file:Main.java
private static boolean isSameHalfDay(Calendar now, Calendar msg) { int nowHour = now.get(Calendar.HOUR_OF_DAY); int msgHOur = msg.get(Calendar.HOUR_OF_DAY); if (nowHour <= 12 & msgHOur <= 12) { return true; } else if (nowHour >= 12 & msgHOur >= 12) { return true; } else {// w w w. jav a 2 s .co m return false; } }
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
public static Calendar getEndOfDate(long time) { Calendar ret = Calendar.getInstance(); ret.setTimeInMillis(time);//from www . ja va 2 s .co 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
static private Calendar getCalendarAlarmTime(int hour, int minute) { Calendar alarmTime = Calendar.getInstance(); alarmTime.set(Calendar.HOUR_OF_DAY, hour); alarmTime.set(Calendar.MINUTE, minute); alarmTime.set(Calendar.SECOND, 0); return alarmTime; }
From source file:Main.java
public static Calendar tomorrow() { Calendar tomorrow = new GregorianCalendar(); tomorrow.set(Calendar.HOUR_OF_DAY, 0); tomorrow.set(Calendar.MINUTE, 0); tomorrow.set(Calendar.SECOND, 0); tomorrow.set(Calendar.MILLISECOND, 0); tomorrow.add(Calendar.DAY_OF_MONTH, 1); return tomorrow; }
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);/*from ww w . j a v a2s. c o m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTimeInMillis(); }