Java Utililty Methods Date Start

List of utility methods to do Date Start

Description

The list of methods to do Date Start are organized into topic(s).

Method

DategetStartOfDay(Date date)
get Start Of Day
Calendar cal = new GregorianCalendar();
cal.setTime(date);
cal.set(Calendar.HOUR, -12);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
date = cal.getTime();
return date;
DategetStartOfDay(Date date)
Set the time component as the start of the day.
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
Date start = getDate(year, month, day);
return start;
longgetStartOfDay(Date day)
get Start Of Day
Calendar startOfDay = Calendar.getInstance();
startOfDay.setTime(day);
startOfDay.set(Calendar.HOUR_OF_DAY, 0);
startOfDay.set(Calendar.MINUTE, 0);
startOfDay.set(Calendar.SECOND, 0);
startOfDay.set(Calendar.MILLISECOND, 0);
return startOfDay.getTimeInMillis();
DategetStartOfDay(Date day)
get Start Of Day
Calendar calendar = Calendar.getInstance();
calendar.setTime(day);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
DategetStartOfMonth(Date date)
get Start Of Month
java.util.Calendar cal = java.util.Calendar.getInstance();
cal.setTime(date);
cal.set(java.util.Calendar.DATE, 1);
return cal.getTime();
DategetStartOfMonth(Date dt)
Return the first day of the month from the Date given Hour, minutes, seconds are set to 0:00:00
if (dt == null)
    return null;
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(dt);
gc.set(Calendar.DAY_OF_MONTH, 1);
gc.set(Calendar.HOUR_OF_DAY, 0);
gc.set(Calendar.MINUTE, 0);
gc.set(Calendar.SECOND, 0);
...
DategetStartOfMonth(Date dt)
Get the start of the month
Calendar c = Calendar.getInstance();
c.setTime(dt);
c.set(Calendar.DAY_OF_MONTH, 1);
return c.getTime();
DategetStartOfQuarter(Date dt)
Return the first day of the set quarter from the Date given.
if (dt == null)
    return null;
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(dt);
int thisMonth = gc.get(Calendar.MONTH);
switch (thisMonth) {
case Calendar.JANUARY:
case Calendar.FEBRUARY:
...
DategetStartTimeByManDay(Date serviceStartTime)
get Start Time By Man Day
if (serviceStartTime == null) {
    return null;
Calendar startTime = Calendar.getInstance();
startTime.setTime(serviceStartTime);
startTime.set(Calendar.MINUTE, 0);
startTime.set(Calendar.SECOND, 0);
startTime.set(Calendar.MILLISECOND, 0);
...
DategetStartTimeOfDate(Date date)
get Start Time Of Date
Calendar calendar = getCalendarByDate(date);
calendar.set(11, 0);
calendar.set(12, 0);
calendar.set(13, 0);
calendar.set(14, 0);
return calendar.getTime();