List of utility methods to do Day of
long | calcDay(String date1, String date2, String format) calc Day SimpleDateFormat sdf = new SimpleDateFormat(format); Calendar cal = Calendar.getInstance(); cal.setTime(sdf.parse(date1)); long time1 = cal.getTimeInMillis(); cal.setTime(sdf.parse(date2)); long time2 = cal.getTimeInMillis(); return (time1 - time2) / (1000 * 3600 * 24); |
String | calcSunday(String queryDate) calc Sunday String result = null; if (queryDate != null) { GregorianCalendar gc = new GregorianCalendar(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); try { gc.setTime(df.parse(queryDate)); gc.add(5, -1); for (; gc.get(7) != 7; gc.add(5, 1)) ... |
int | CountCmpHolidays(Date stdate, Date enddate, String[] CmpHoliDays) Count Cmp Holidays int NonWorkingDays = 0; Calendar c1 = Calendar.getInstance(); DateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); try { c1.setTime(stdate); while ((stdate.compareTo(enddate)) < 0) { if (Arrays.binarySearch(CmpHoliDays, sdf1.format(c1.getTime())) >= 0) { NonWorkingDays += 1; ... |
long | countDay(String begin, String end) count Day SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date beginDate, endDate; long day = 0; try { beginDate = format.parse(begin); endDate = format.parse(end); day = (endDate.getTime() - beginDate.getTime()) / (24 * 60 * 60 * 1000); } catch (ParseException e) { ... |
Date | endOfTheDay(Date date) end Of The Day Calendar c = new GregorianCalendar(); c.setTime(date); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59); c.set(Calendar.SECOND, 59); c.set(Calendar.MILLISECOND, 0); return c.getTime(); |
String | formatDate(String day) format Date try { return yyyyMM.format(formatYearMonth(day)); } catch (Exception ex) { ex.printStackTrace(); return null; |
String | formatDay(final Date time) Formats the given time using the following pattern: 'MMM d, yyyy'. final SimpleDateFormat dateTimeFormat = new SimpleDateFormat(DAY); dateTimeFormat.setTimeZone(TimeZone.getDefault()); return time != null ? dateTimeFormat.format(time) : ""; |
java.util.Date | formatDayTime(String day) format Day Time try { return yyyyMMdd.parse(day); } catch (ParseException ex) { ex.printStackTrace(); return new java.util.Date(); |
String | formatShortNameOfDay(final Date date) format Short Name Of Day final DateFormat df = new SimpleDateFormat("EE", Locale.getDefault()); df.setTimeZone(TimeZone.getDefault()); return df.format(date); |
String | get1DayBeforDate() get Day Befor Date Calendar now = Calendar.getInstance(); now.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH) - 1); return getDate(now.getTime(), "yyyy-MM-dd"); |