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 String createCCPFileName() { Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis()); int y = c.get(Calendar.YEAR); int m = c.get(Calendar.MONTH); int d = c.get(Calendar.DAY_OF_MONTH); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); int second = c.get(Calendar.SECOND); return y + "-" + m + "-" + d + "-" + hour + "-" + minute + "-" + second; }
From source file:Main.java
private static Calendar clearTimes(Calendar c) { c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0);/*from w w w . j a va 2 s . com*/ c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c; }
From source file:Main.java
@NonNull public static String getTime() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-" + calendar.get(Calendar.DAY_OF_MONTH) + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND); }
From source file:Main.java
public static Calendar calculateNextAlarmTime(int repetition) { if (repetition == 0) return null; Calendar alarmTime = Calendar.getInstance(); alarmTime.set(Calendar.HOUR_OF_DAY, 20); alarmTime.set(Calendar.MINUTE, 0); alarmTime.set(Calendar.SECOND, 0); int day_of_week = alarmTime.get(Calendar.DAY_OF_WEEK) - 2; if (day_of_week == -1) day_of_week = 6;// sunday repetition &= 0x7f;/*from w w w . ja va 2s.co m*/ int rot = (repetition >> (day_of_week + 1)) | (repetition << (7 - day_of_week - 1)); rot &= 0x7f; int ndays = 0; for (ndays = 0; ndays < 7; ndays++) { if ((rot & (1 << ndays)) != 0) break; } alarmTime.add(Calendar.DATE, ndays + 1); return alarmTime; }
From source file:Main.java
public static Long getToday() { Calendar today = Calendar.getInstance(); today.setTimeZone(TimeZone.getDefault()); today.set(Calendar.SECOND, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.HOUR_OF_DAY, 1); today.set(Calendar.MILLISECOND, 0); // FOR DEBUG//from ww w . j a va 2 s. c om //today.set(Calendar.DAY_OF_YEAR, today.get(Calendar.DAY_OF_YEAR) + 1); return today.getTimeInMillis(); }
From source file:Main.java
/** * Given a calendar date, find a logical end time for an event. Most likely one hour later. * @param fromCalendar// ww w . j a v a2s . co m * @return endCalendar */ public static Calendar getLogicalEnd(Calendar fromCalendar) { Calendar endCalendar = (Calendar) fromCalendar.clone(); endCalendar.add(Calendar.HOUR_OF_DAY, 1); return endCalendar; }
From source file:Main.java
public static long getEndOfDayMs(int year, int month, int day) { final Calendar date = Calendar.getInstance(); date.set(Calendar.YEAR, year); date.set(Calendar.MONTH, month); date.set(Calendar.DAY_OF_MONTH, day); date.set(Calendar.HOUR_OF_DAY, date.getActualMaximum(Calendar.HOUR_OF_DAY)); date.set(Calendar.MINUTE, date.getActualMaximum(Calendar.MINUTE)); date.set(Calendar.SECOND, date.getActualMaximum(Calendar.SECOND)); date.set(Calendar.MILLISECOND, date.getActualMaximum(Calendar.MILLISECOND)); return date.getTimeInMillis(); }
From source file:Main.java
public static long getStartOfDayMs(int year, int month, int day) { final Calendar date = Calendar.getInstance(); date.set(Calendar.YEAR, year); date.set(Calendar.MONTH, month); date.set(Calendar.DAY_OF_MONTH, day); date.set(Calendar.HOUR_OF_DAY, date.getActualMinimum(Calendar.HOUR_OF_DAY)); date.set(Calendar.MINUTE, date.getActualMinimum(Calendar.MINUTE)); date.set(Calendar.SECOND, date.getActualMinimum(Calendar.SECOND)); date.set(Calendar.MILLISECOND, date.getActualMinimum(Calendar.MILLISECOND)); return date.getTimeInMillis(); }
From source file:Main.java
public static Date getDate(int year, int month, int day) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, day); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);// w w w .j a v a 2 s. c o m cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
From source file:Main.java
public static String getDateString(long millitm) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(millitm);// w ww. jav a2s . com return (setZeroPad(cal.get(Calendar.YEAR)) + "/" + setZeroPad(cal.get(Calendar.MONTH)) + "/" + setZeroPad(cal.get(Calendar.DATE)) + " " + setZeroPad(cal.get(Calendar.HOUR_OF_DAY)) + ":" + setZeroPad(cal.get(Calendar.MINUTE)) + ":" + setZeroPad(cal.get(Calendar.SECOND))); }