List of utility methods to do Hour
String | getHourAndMinutes(Date dt) Get and return the hours and minutes from the given Date dt, ex: 11:30 Calendar cal = new GregorianCalendar(); cal.setTime(dt); return (cal.get(Calendar.HOUR) + ":" + (cal.get(Calendar.MINUTE))); |
Date | getHourBeforeTime(int hour) get Hour Before Time Calendar now = Calendar.getInstance();
now.set(Calendar.HOUR_OF_DAY, now.get(Calendar.HOUR_OF_DAY) - hour);
return now.getTime();
|
Calendar | getHourByZore(int hour) get Hour By Zore Calendar c = Calendar.getInstance();
c.add(Calendar.DAY_OF_MONTH, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.HOUR_OF_DAY, hour);
return c;
|
String | getHourDetails(int timeInfo) get Hour Details Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.set(Calendar.HOUR_OF_DAY, timeInfo); SimpleDateFormat formatter = new SimpleDateFormat("dd/MMM/yyyy HH:MM"); return formatter.format(cal.getTime()); |
String | getHourFormatedTwoDigit() get Hour Formated Two Digit return intTwoDigit(getHour());
|
Integer | getHourFromDate(Date date) get Hour From Date Integer result = null; if (date != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); result = calendar.get(Calendar.HOUR); return result; |
int | getHourInt() get Hour Int Calendar ca = Calendar.getInstance(); ca.setTime(new Date()); return ca.get(Calendar.HOUR_OF_DAY); |
String | getHourMin(Date date) get Hour Min Calendar cal = Calendar.getInstance(); cal.setTime(date); String ohHour = cal.get(Calendar.HOUR_OF_DAY) + ""; String ohMinute = cal.get(Calendar.MINUTE) + ""; if (ohMinute.length() == 1) { ohMinute = "0" + ohMinute; if (ohHour.length() == 1) { ... |
String | getHourMinuteSecondByMisSecond(long misSecond) get Hour Minute Second By Mis Second if (misSecond < 0) { throw new IllegalArgumentException("The misSecond must not be negative"); if (misSecond == 0) { return "--"; Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(misSecond); ... |
String | getHourMinuteString(Date dateTime) get Hour Minute String return new SimpleDateFormat("H:mm").format(dateTime); |