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

DategetLateInTheDay(Date date)
get Late In The Day
String dateString = new SimpleDateFormat(SHORT_DATE_FORMAT_STR).format(date) + " " + LATE_TIME;
return new SimpleDateFormat(LONG_DATE_FORMAT_STR).parse(dateString);
MapgetLatest7Day()
get Latest Day
String todayStr = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
todayStr = sdf.format(new Date(System.currentTimeMillis()));
todayStr = todayStr + " 00:00:00";
Date today = new Date();
DateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Map<String, Long[]> data = new TreeMap<>();
try {
...
StringgetNDayAfterCurrentDate(String dateStr, String dateFormat, int n)
get N Day After Current Date
try {
    Calendar c = Calendar.getInstance();
    Date date = parse(dateStr, dateFormat);
    c.setTime(date);
    c.add(c.DAY_OF_MONTH, n);
    return c.get(c.YEAR) + "-" + (c.get(c.MONTH) + 1) + "-" + c.get(c.DATE);
} catch (ParseException e) {
    e.printStackTrace();
...
DateFormatgetOtherDayLastUpdateTimeFormat()
get Other Day Last Update Time Format
return otherDayLastUpdateTimeFormat.get();
StringgetPaxBirthday()
get Pax Birthday
int i = -(3 + getRandomNumber(70));
Date date = new Date();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.YEAR, i);
cal.add(Calendar.HOUR, getRandomNumber(50));
cal.add(Calendar.MONTH, getRandomNumber(9));
date = cal.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyMMdd");
...
StringgetPriorDay(int offset, String pattern)
get Prior Day
SimpleDateFormat timeFormat = new SimpleDateFormat(pattern);
Calendar theday = Calendar.getInstance();
theday.add(5, offset);
return timeFormat.format(theday.getTime());
DategetRunningTime(Date date, SimpleDateFormat sday, String line)
Gets the time the app was running for each day
long diff = (date.getTime() - sday.parse(line).getTime()) - 60 * 60 * 1000;
return new Date(diff);
StringgetSetDate(Date dt, int dayNum)
get Set Date
StringBuffer str = new StringBuffer();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar lastDate = Calendar.getInstance();
lastDate.add(Calendar.DATE, dayNum);
str.append(sdf.format(lastDate.getTime()));
return str.toString();
intgetSignContinusDay(Date lastSignTime)
get Sign Continus Day
Date date = new Date();
SimpleDateFormat datetr = new SimpleDateFormat("yyyyMMdd");
String lastSign = datetr.format(lastSignTime);
String nowDay = datetr.format(date);
int lastSignDay = Integer.parseInt(lastSign);
int newDay = Integer.parseInt(nowDay);
return newDay - lastSignDay;
Date[]getSpcilNumDayArray(Date startDate, int num)
get Spcil Num Day Array
Date[] dates = new Date[2];
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
    dates[0] = sdf.parse(format(startDate, "yyyy-MM-dd"));
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(dates[0]);
    calendar.add(Calendar.DATE, num);
    calendar.add(Calendar.SECOND, -1);
...