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

intgetHour(Date now)
get Hour
Calendar calendar = getCalendarFromDate(now);
return calendar.get(Calendar.HOUR_OF_DAY);
intgetHour(final Date timeFrom)
Gets the hour.
final Calendar instance = Calendar.getInstance();
instance.setTime(timeFrom);
final int hour = instance.get(Calendar.HOUR);
return hour;
intgetHour(java.util.Date date)
get Hour
java.util.Calendar c = java.util.Calendar.getInstance();
c.setTime(date);
return c.get(java.util.Calendar.HOUR_OF_DAY);
intgetHour(long t)
get Hour
Calendar cld = Calendar.getInstance();
if (t > 0) {
    cld.setTime(new java.util.Date(t));
return cld.get(Calendar.HOUR_OF_DAY);
intgetHour(String dateString)
get Hour
Calendar calendar = getCalendar(dateString);
return calendar.get(Calendar.HOUR_OF_DAY);
intgetHour(String dateTime)
get Hour
Date date = null;
try {
    date = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(dateTime);
} catch (ParseException e) {
    e.printStackTrace();
Calendar now = Calendar.getInstance();
now.setTime(date);
...
intgetHour12(Date date)
Return hour12.
return getCalendar(date).get(Calendar.HOUR);
DategetHourAfter(Date date, int hour)
get Hour After
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR, hour + 1);
return calendar.getTime();
DategetHourAfter(final Date _from, final int _hours)
get Hour After
return getDateTimeAfter(_from, Calendar.HOUR_OF_DAY, _hours);
StringgetHourAndMin(long time)
get Hour And Min
SimpleDateFormat format = new SimpleDateFormat("HH:mm");
return format.format(new Date(time));