Java Utililty Methods Hour

List of utility methods to do Hour

Description

The list of methods to do Hour are organized into topic(s).

Method

DategetHoursByDate(Date date, int hours)
get Hours By Date
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
cal.add(Calendar.HOUR_OF_DAY, hours);
return cal.getTime();
longgetHoursOfTowDiffDate(String p_startDate, String p_endDate)
get Hours Of Tow Diff Date
return (long) getMillisOfTowDiffDate(p_startDate, p_endDate) / (1000 * 60 * 60);
StringgetLastHour()
get Last Hour
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHH");
Calendar cl = Calendar.getInstance();
cl.set(cl.get(cl.YEAR), cl.get(cl.MONTH), cl.get(cl.DAY_OF_MONTH), cl.get(cl.HOUR_OF_DAY) - 1, 0, 0);
return sf.format(cl.getTime());
StringgetLasthour()
get Lasthour
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR_OF_DAY, -1);
String yesterday = new SimpleDateFormat("yyyy-MM-dd HH").format(cal.getTime());
return yesterday;
intgetMinOfHour(long l1)
get Min Of Hour
Calendar cal1 = Calendar.getInstance();
cal1.setTimeInMillis(l1);
return cal1.get(Calendar.MINUTE);
intgetPreHour()
get Pre Hour
Calendar now = Calendar.getInstance();
now.add(Calendar.HOUR_OF_DAY, -1);
return now.get(Calendar.HOUR_OF_DAY);
StringgetPreHourText(String pattern)
get Pre Hour Text
Calendar c = Calendar.getInstance();
return getPreHourText(c.getTime(), pattern);
DategetPrevHour(Date date)
get Prev Hour
return new Date(date.getTime() - 60 * MINUTE_MILLISECONDS);
intgetSecondsPassedInHour()
get Seconds Passed In Hour
Calendar cur = GregorianCalendar.getInstance();
Calendar calendar = GregorianCalendar.getInstance();
calendar.set(cur.get(Calendar.YEAR), cur.get(Calendar.MONTH), cur.get(Calendar.DATE),
        cur.get(Calendar.HOUR_OF_DAY), 0);
long currenttime = cur.getTime().getTime();
long hourtime = calendar.getTime().getTime();
long millis = currenttime - hourtime;
int result = (int) (millis / 1000);
...
DategetTaskTrigger(int taskTriggerHour, boolean tomorrow)
Get date of next time for triggering task
return getTaskTrigger(taskTriggerHour, 0, tomorrow);