List of utility methods to do Date Set
Date | toDateTime(Date date, Date time) to Date Time if (date == null) return null; if (time == null) return date; Calendar d = new GregorianCalendar(); d.setTime(date); Calendar t = new GregorianCalendar(); t.setTime(time); ... |
Date | offsetDate(Date date, int field, int offset) offset Date Calendar calendar = convert(date);
calendar.add(field, offset);
return calendar.getTime();
|
String | changeDate(String argDate) change Date if (argDate == null || argDate.trim().equals("")) { return ""; String result = ""; if (argDate.length() == 10 && argDate.indexOf("/") > 0) { return argDate; String[] str = argDate.split("[.]"); ... |
Date | firstTimeOfDate(Date date) first Time Of Date Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(date.getTime()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); Date dateBegin = new Date(); dateBegin.setTime(calendar.getTimeInMillis()); return dateBegin; |
Date | resetTime(Date date) reset Time Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
|
Date | removeTime(Date date) Remove the time of a date value GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date); gc.set(Calendar.HOUR_OF_DAY, 0); gc.set(Calendar.MINUTE, 0); gc.set(Calendar.SECOND, 0); gc.set(Calendar.MILLISECOND, 0); return gc.getTime(); |