Java Utililty Methods Date Start

List of utility methods to do Date Start

  1. HOME
  2. Java
  3. D
  4. Date Start

Description

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

Method

Date getStart(Date date)
Returns the given date with the time set to the start of the day.
return clearTime(date);
Date getStartDate(Date date)
get Start Date
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
return calendar.getTime();
Date getStartDate(Date date)
get Start Date
return getFirstOfMonthCalendar(date).getTime();
Date getStartDate(Date date)

Description:Get Monday of the week the day specified by parameter belongs to

Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int day = calendar.get(Calendar.DAY_OF_WEEK);
int offset = offsets[day - Calendar.SUNDAY];
calendar.add(Calendar.DAY_OF_YEAR, offset);
return calendar.getTime();
String getStartDate(String date)
get Start Date
String startDate;
int year = getYear(date);
int month = getMonth(date);
int day = getDate(date);
int curDayOfWeek = getDayOfWeek(year, month, day);
int startTmp = 1 - curDayOfWeek;
Calendar tmpCalendar = Calendar.getInstance();
tmpCalendar.set(year, month - 1, day);
...
Date getStartDateOfCurrentSemester()
get Start Date Of Current Semester
Calendar cal = Calendar.getInstance();
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
if (month >= 9 && month <= 2) {
 cal.set(year, Calendar.OCTOBER, 1, 0, 0, 0);
 return cal.getTime();
} else {
 cal.set(year, Calendar.APRIL, 1, 0, 0, 0);
...
Date getStartDateOfCurrMonth()
get Start Date Of Curr Month
Calendar now = Calendar.getInstance();
now.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), 1);
return now.getTime();
GregorianCalendar getStartDay(Date date)
get Start Day
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
for (int field = 0; field < 5; field++)
 cal.set(ORDERED_DATE_FIELD[field], 0);
return cal;
Date getStartDayOfNextMonth(Date date)
get Start Day Of Next Month
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.MONTH, 1);
c.set(Calendar.DAY_OF_MONTH, 1);
date = c.getTime();
return date;
Date getStartOfDate(final Date date)
Get start of date.
if (date == null)
 return null;
Calendar cal = GregorianCalendar.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);
...


AltStyle によって変換されたページ (->オリジナル) /