List of utility methods to do Date to Time
Calendar | getTime(Date date) Derives a Calendar object from a Date object return getTime(date.getTime());
|
String | getTime(Date date) get Time return format(date, "HH:mm:ss"); |
int | getTime(Date date) get Time Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int hour = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); return hour * 10000 + minute * 100 + second; |
long | getTime(Date date, boolean isEnd) get Time Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); if (isEnd) { calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MILLISECOND, 999); ... |
String | getTime(Date date, String pattern, Locale locale) get Time SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); return formatter.format(date); |
long | getTime(Date dateParam) get Time if (dateParam == null) { throw new IllegalArgumentException("The dateParam must not be null"); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(dateParam.getTime()); int hour = cal.get(Calendar.HOUR); int minute = cal.get(Calendar.MINUTE); int second = cal.get(Calendar.SECOND); ... |
String | getTime(Date executionTime) get Time SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); return formatter.format(executionTime); |
byte[] | getTime(Date timestamp) Return a time in Davis Vantage Pro format (two bytes). Calendar cal = Calendar.getInstance(); cal.setTime(timestamp); int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); int value = hour * 100 + minute; return getBytes(value); |
String | getTime(Date trialTime) get Time return dateToString(trialTime, DF_HMS);
|
Date | getTime(final Date date, final int day) get Time final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) + day); return calendar.getTime(); |