List of utility methods to do Hour
long | getTicksTill(int hour) Gets the ticks till a given base 24 hour return getTicksTill(hour, -1);
|
long | getTicksTillHour() Gets the ticks till the start of the next hour Calendar localCalendar = Calendar.getInstance(); long returnValue; localCalendar.set(Calendar.MINUTE, 0); localCalendar.add(Calendar.HOUR_OF_DAY, 1); returnValue = localCalendar.getTimeInMillis() - calendar.getTimeInMillis(); returnValue = (returnValue / 1000) * 20; return returnValue; |
int | hour() Returns the current hour as a value from 0 - 23. return new GregorianCalendar().get(Calendar.HOUR_OF_DAY); |
int | hour() hour return calendar().get(Calendar.HOUR);
|
Date | hourAgo() Get date for hour ago from now return forCalendarDiff(Calendar.HOUR, -1);
|
String | hourCompletion(boolean hourPresent, int hour, boolean minutePresent, int minute, boolean secondPresent, int second, boolean milliPresent, int milli, String choice) hour Completion String result = new String(); if (!choice.equals("hour") && !choice.equals("minute") && !choice.equals("second") && !choice.equals("milli")) throw new RuntimeException("Unrecognize parameter 'choice'"); Calendar calendar = Calendar.getInstance(); int state; if (hourPresent) { if (minutePresent) { ... |
String | HourNow() Hour Now int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY); int min = Calendar.getInstance().get(Calendar.MINUTE); int sec = Calendar.getInstance().get(Calendar.SECOND); return "[" + hour + ":" + min + ":" + sec + "]"; |
String | Hours() Hours Calendar c = Calendar.getInstance(); c.setTime(new Date()); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int date = c.get(Calendar.DATE); int hour = c.get(Calendar.HOUR_OF_DAY); return year + "-" + (month < 10 ? "0" : "") + month + "-" + (date < 10 ? "0" : "") + date + "-" + (hour < 10 ? "0" : "") + hour; ... |
Date | hours(int hours) hours return hours(new Date(), hours); |
int | hoursAndMinsToMilliseconds(int sign, int hours, int minutes) Converts a number of hours, minutes and seconds and a corresponding sign value to an equivalent offset value from UTC (Universal Coordinated Time), measured in milliseconds. sign = (sign >= 0) ? 1 : -1; hours = (hours >= 0) ? hours : -hours; minutes = (minutes >= 0) ? minutes : -minutes; if ((hours > 30) || (minutes > 1800)) throw new IllegalArgumentException( "The magnitude of one or both of the hours or minutes value is outside the acceptable range."); return sign * (hours * 3600000 + minutes * 60000); |