Java Utililty Methods Day End

List of utility methods to do Day End

Description

The list of methods to do Day End are organized into topic(s).

Method

ListgetDatebetweenOfDays(Date startDate, Date endDate)
get Datebetween Of Days
List<Date> list = new ArrayList<Date>();
GregorianCalendar gc1 = new GregorianCalendar(), gc2 = new GregorianCalendar();
gc1.setTime(startDate);
gc2.setTime(endDate);
do {
    GregorianCalendar gc3 = (GregorianCalendar) gc1.clone();
    list.add(gc3.getTime());
    System.out.println(gc3.getTime());
...
java.util.DategetDateEnd(java.util.Date d)
get Date End
Calendar c = Calendar.getInstance();
c.clear();
Calendar co = Calendar.getInstance();
co.setTime(d);
c.set(Calendar.DAY_OF_MONTH, co.get(Calendar.DAY_OF_MONTH));
c.set(Calendar.MONTH, co.get(Calendar.MONTH));
c.set(Calendar.YEAR, co.get(Calendar.YEAR));
c.add(Calendar.DAY_OF_MONTH, 1);
...
DategetDateEndDay()
get Date End Day
return getDateEndDay(getDateNow());
DategetDateInterval4EndDate(Date date, int hourModify)
get Date Interval End Date
Calendar c = Calendar.getInstance();
c.setTime(date);
int second = c.get(Calendar.SECOND);
int hour = c.get(Calendar.HOUR);
c.set(Calendar.SECOND, second + 3);
c.set(Calendar.HOUR, hour - hourModify);
return c.getTime();
ListgetDateList(Date begin, Date end)
get Date List
int differ = getDifferDays(begin, end);
List<Date> temp = new ArrayList<Date>(differ);
for (int i = 0; i <= differ; i++) {
    CALENDAR.setTime(begin);
    CALENDAR.add(Calendar.DATE, i);
    temp.add(CALENDAR.getTime());
return temp;
...
ListgetDatesBetweenTwoDate(Date beginDate, Date endDate)
get Dates Between Two Date
List<Date> dateList = new ArrayList<Date>();
dateList.add(beginDate);
Calendar cal = Calendar.getInstance();
cal.setTime(beginDate);
boolean bContinue = true;
while (bContinue) {
    cal.add(Calendar.SECOND, 1);
    if (endDate.after(cal.getTime())) {
...
StringgetDateTimeString(boolean appendMillis)
get Date Time String
StringBuilder b = new StringBuilder();
Calendar cal = Calendar.getInstance();
b.append(getFixedString(cal.get(Calendar.YEAR), 4));
b.append(getFixedString(cal.get(Calendar.MONTH) + 1, 2));
b.append(getFixedString(cal.get(Calendar.DAY_OF_MONTH), 2));
b.append("_");
b.append(getFixedString(cal.get(Calendar.HOUR_OF_DAY), 2));
b.append(getFixedString(cal.get(Calendar.MINUTE), 2));
...
CalendargetDefaultEndDateForLogQuery()
get Default End Date For Log Query
Calendar endDate = Calendar.getInstance();
endDate.set(Calendar.HOUR_OF_DAY, LAST_HOUR);
endDate.set(Calendar.MINUTE, LAST_MINUTE);
endDate.set(Calendar.SECOND, LAST_SECOND);
endDate.set(Calendar.MILLISECOND, LAST_MILLISECOND);
return endDate;
longgetDistDates(Date startDate, Date endDate)
get Dist Dates
long totalDate = 0;
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
long timestart = calendar.getTimeInMillis();
calendar.setTime(endDate);
long timeend = calendar.getTimeInMillis();
totalDate = Math.abs((timeend - timestart)) / (1000 * 60 * 60 * 24);
return totalDate;
...
CalendargetEndDate()
Gets the end date.
Calendar calendarEndDate = Calendar.getInstance();
calendarEndDate.add(Calendar.YEAR, 1);
return calendarEndDate;