Java Utililty Methods Day of

List of utility methods to do Day of

Description

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

Method

Stringget8BitTime(Date date, int deltaDay)
get Bit Time
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DAY_OF_YEAR, deltaDay);
return format.format(cal.getTime());
ListgetAfterDays(String date, String pattern, int afterDays)
get After Days
List<String> list = new ArrayList<String>();
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
Date getDate = sdf.parse(date);
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(getDate);
for (int i = 0; i < afterDays; i++) {
    gc.add(Calendar.DATE, 1);
    getDate = gc.getTime();
...
intgetAge(Date birthDay)
get Age
Calendar cal = Calendar.getInstance();
if (cal.before(birthDay)) {
    throw new IllegalArgumentException("The birthDay is before Now.It's unbelievable!");
int yearNow = cal.get(Calendar.YEAR);
int monthNow = cal.get(Calendar.MONTH);
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
cal.setTime(birthDay);
...
intgetAgeOfCalendar(String birthDayString)
get Age Of Calendar
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date birthDay = df.parse(birthDayString);
Calendar cal = Calendar.getInstance();
int yearNow = cal.get(Calendar.YEAR);
int monthNow = cal.get(Calendar.MONTH);
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
cal.setTime(birthDay);
int yearBirth = cal.get(Calendar.YEAR);
...
StringgetApisPaxBirthday(String dob)
get Apis Pax Birthday
int day = Integer.parseInt(dob.substring(0, 2));
String month = dob.substring(2, 5);
int mon = 1;
switch (month) {
case "JAN":
    mon = 1;
    break;
case "FEB":
...
DategetBeforeDate(int day)
get Before Date
Calendar cl = Calendar.getInstance();
Long clTemp = cl.getTimeInMillis() - day * 24 * 60 * 60 * 1000L;
cl.setTimeInMillis(clTemp);
return getFormatDate(cl.getTime(), "yyyy-MM-dd");
StringgetBeforeOrAfterDay(Date date, String format, Integer days)
get Before Or After Day
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_MONTH, days);
SimpleDateFormat df = new SimpleDateFormat(format);
return df.format(calendar.getTime());
Date[]getBeginEndTimeOfDay(Date day)
Returns the begin/end time of the given day
Date begin, end;
begin = day;
Calendar cal = getCalendar();
cal.setTime(begin);
cal.set(Calendar.HOUR, 23);
cal.add(Calendar.MINUTE, 59);
cal.add(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
...
DategetBeginOfDay(Date date)
get Begin Of Day
String beginDay = new SimpleDateFormat(EARER_IN_THE_DAY).format(date);
try {
    return parserStringToDate(beginDay, LONG_DATE_FORMAT_STR);
} catch (ParseException e) {
return null;
longgetBeginTimeOfDay(Date date, int offset)
get Begin Time Of Day
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_YEAR, offset);
date = calendar.getTime();
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
return Long.valueOf(dateFormat.format(date) + "0000");