List of utility methods to do Day of
Date | parseFromDays(String date) Parses a string of the following format to a Date : return parse(getFormatToDays(), date);
|
Date | plusDay(Date date, int day) plus Day Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, day);
return cal.getTime();
|
Date | plusDays(Date date, int days) plus Days if (date == null) date = getToday(); return changeDays(date, days); |
Date | setDays(Date date, int amount) Sets the day of month field to a date returning a new object. return set(date, Calendar.DAY_OF_MONTH, amount);
|
String | startOfDay(Date date, String format) start Of Day SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(startOfDay(date)); |
String | stringSomeDaysAgo(Date currentTime, int days) string Some Days Ago if (currentTime == null) return ""; Calendar cal = Calendar.getInstance(); cal.setTime(currentTime); cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - days); return convertDate2String5(cal.getTime()); |
Date | strToShortday(String s) str To Shortday try { SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd"); ParsePosition parseposition = new ParsePosition(0); return simpledateformat.parse(s, parseposition); } catch (Exception e) { return null; |
Date | subtractDate(Date d, long day) subtract Date long time = d.getTime(); day = day * 24 * 60 * 60 * 1000; time -= day; return new Date(time); |
String | toCurrentDatedefer(int day) to Current Datedefer GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(new Date()); calendar.add(GregorianCalendar.DAY_OF_MONTH, day); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); return format.format(calendar.getTime()); |
String | ToEnglishDay(Date dt) To English Day if (dt == null) return ""; DateFormatSymbols sym = new DateFormatSymbols(); sym.setMonths(MONTHS); SimpleDateFormat f = new SimpleDateFormat("dd MMM, yyyy", sym); return f.format(dt); |