List of utility methods to do Date to Day
int | getDayShort(Date date) get Day Short Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(START_2011); Calendar targetCalendar = Calendar.getInstance(); targetCalendar.setTime(date); targetCalendar.set(Calendar.HOUR_OF_DAY, 0); targetCalendar.set(Calendar.MINUTE, 0); targetCalendar.set(Calendar.SECOND, 0); targetCalendar.set(Calendar.MILLISECOND, 0); ... |
long | getDaysMin(Date d) get Days Min Calendar c1 = new GregorianCalendar(); c1.setTime(d); long m = c1.get(Calendar.MINUTE); return m; |
int | getDaysPassedSince(Date dateLastModified) Returns the number of days passed since a specific date.
GregorianCalendar now = new GregorianCalendar(); GregorianCalendar lastModified = (GregorianCalendar) now.clone(); lastModified.setTimeInMillis(dateLastModified.getTime()); return now.get(Calendar.DAY_OF_YEAR) - lastModified.get(Calendar.DAY_OF_YEAR) + (now.get(Calendar.YEAR) - lastModified.get(Calendar.YEAR)) * 365; |
Date | getDayStart(Date date) get Day Start Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 00);
cal.set(Calendar.MINUTE, 00);
cal.set(Calendar.SECOND, 00);
return cal.getTime();
|
Date | getDayStart(final Date date) Get a Date representing the start of the day for the specified date. return getDayStart(date, null);
|
Long | getDaysToLong(Date date1, Date date2) get Days To Long Long d1 = getYmdTime(date1).getTime() / 1000;
Long d2 = getYmdTime(date2).getTime() / 1000;
return Math.abs((d2 - d1)) / (24 * 3600);
|
Date | getDayTime(Date date, int hour, int minute, int second) get Day Time GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date); gc.set(Calendar.HOUR_OF_DAY, hour); gc.set(Calendar.MINUTE, minute); gc.set(Calendar.SECOND, second); return gc.getTime(); |