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 boolean isValidDate() { Calendar calendar = Calendar.getInstance(); int hours = calendar.get(Calendar.HOUR_OF_DAY); if (hours > 7) { return true; }/*from w w w. j ava 2 s. c om*/ return false; }
From source file:Main.java
public static Calendar getFirstDayOfWeek() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);//from w w w . jav a 2s .com cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal; }
From source file:Main.java
public static Calendar getTodayAt(int hours) { Calendar today = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hours); return calendar; }
From source file:Main.java
public static Date dayBegin(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);/*from www. j a v a 2s. c o m*/ 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(); }
From source file:Main.java
public static long getBeginOfCurrentDateInMillis() { Calendar calendar = Calendar.getInstance(); calendar.clear(Calendar.HOUR); calendar.clear(Calendar.HOUR_OF_DAY); calendar.clear(Calendar.MINUTE); calendar.clear(Calendar.SECOND); calendar.clear(Calendar.MILLISECOND); return calendar.getTimeInMillis(); }
From source file:Main.java
public static Date getNearestFutureDateWithHour(int hourOfDay) { Calendar cal = Calendar.getInstance(); int hourOfDayNow = cal.get(Calendar.HOUR_OF_DAY); if (hourOfDayNow > hourOfDay) { cal.add(Calendar.DAY_OF_MONTH, 1); }/*from w w w .j a v a2s .c o m*/ cal.set(Calendar.HOUR, hourOfDay); return cal.getTime(); }
From source file:Main.java
private static long getTimeInMillis() { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 21); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); return calendar.getTimeInMillis(); }
From source file:Main.java
public static Calendar tomorrow() { Calendar date = new GregorianCalendar(); date.add(Calendar.DATE, 1);//from w w w. j a v a 2 s . c om date.set(Calendar.HOUR_OF_DAY, 0); date.set(Calendar.MINUTE, 0); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); return date; }
From source file:Main.java
public static long endOfThisMonth() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); cal.add(Calendar.MONTH, 1);/* w ww . ja v a2 s. c o m*/ cal.add(Calendar.DATE, -1); Date date = cal.getTime(); return date.getTime(); }
From source file:Main.java
public static Calendar roundMinutesAndHour(Calendar time, int TIME_PICKER_INTERVAL) { int minute = time.get(Calendar.MINUTE); int hour = time.get(Calendar.HOUR_OF_DAY); if (time.get(Calendar.MINUTE) % TIME_PICKER_INTERVAL != 0) { int minuteFloor = minute - (minute % TIME_PICKER_INTERVAL); minute = minuteFloor + (minute == minuteFloor + 1 ? TIME_PICKER_INTERVAL : 0); if (minute == 60) { hour++;// www . jav a2 s .c o m minute = 0; } } time.set(Calendar.HOUR_OF_DAY, hour); time.set(Calendar.MINUTE, minute); return time; }