List of utility methods to do Hour
int | getCurrentHours() get Current Hours return Calendar.getInstance().get(Calendar.HOUR);
|
int | getCurrHour() get Curr Hour Calendar c = Calendar.getInstance(); c.setTime(new Date()); return c.get(Calendar.HOUR_OF_DAY); |
long | getDelay(int hour, int min) get Delay if (hour == -1) { return 0; Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.setTime(new Date()); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, min); ... |
long | getDelayToNextHour(int amount, boolean skipNext) This method could be named better, Here is what it does If you want to schedule a task every 2 hours, it is easier to track it if it happens at 2 am, 4 am, 6 am, 8 am .... if (amount <= 0 || amount > 12) { throw new IllegalArgumentException("The amount must be between 1 and 12 and be a divisor of 24"); Calendar c = Calendar.getInstance(); long currentTime = c.getTimeInMillis(); c.clear(Calendar.MINUTE); c.clear(Calendar.SECOND); c.clear(Calendar.MILLISECOND); ... |
int | getGMTHour(int localHour) get GMT Hour Calendar c = Calendar.getInstance(); c.clear(); c.set(Calendar.HOUR_OF_DAY, localHour); Date t = c.getTime(); c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); c.clear(); c.setTime(t); return c.get(Calendar.HOUR_OF_DAY); ... |
String | getHexString(byte[] raw) Converts each byte of the given byte array to a HEX value and returns the concatenation of these values try { byte[] hex = new byte[2 * raw.length]; int index = 0; for (byte b : raw) { int v = b & 0xFF; hex[index++] = HEX_CHAR_TABLE[v >>> 4]; hex[index++] = HEX_CHAR_TABLE[v & 0xF]; return new String(hex, "ASCII"); } catch (UnsupportedEncodingException e) { String msg = MessageFormat.format("Something went wrong while converting to HEX: {0}", e.getMessage()); throw new RuntimeException(msg, e); |
String | getHour() get Hour Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateString = formatter.format(currentTime); String hour; hour = dateString.substring(11, 13); return hour; |
int | getHour() get Hour return CALENDAR.get(11);
|
int | getHour() get Hour return Calendar.getInstance().get(Calendar.HOUR);
|
int | getHour() get Hour Calendar cpcalendar = new GregorianCalendar(); cpcalendar.setTime(getDate()); return cpcalendar.get(Calendar.HOUR_OF_DAY); |