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

StringgetBirthday(String age)
get Birthday
Calendar c = Calendar.getInstance();
c.add(Calendar.YEAR, -Integer.parseInt(age));
SimpleDateFormat format = new SimpleDateFormat(defaultDatePattern);
return format.format(c.getTime());
DategetBirthDay(String idCard)
get Birth Day
String birthDay;
if (idCard.length() == 15) {
    birthDay = "19" + idCard.substring(6, 12);
} else {
    birthDay = idCard.substring(6, 14);
SimpleDateFormat dateFormat = new SimpleDateFormat(DateFormatPattern, Locale.ENGLISH);
return dateFormat.parse(birthDay);
...
DateFormatgetBirthDayDateFormat()
get Birth Day Date Format
return getFormat("MM-dd");
StringgetBirthdayFormatStr(Date date)
get Birthday Format Str
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(date);
StringgetBookInfoDate(int days)
get Book Info Date
Date now = new Date();
return yyyyMmDd.format(new Date(now.getTime() - (long) days * 24 * 60 * 60 * 1000));
CalendargetCalendarByDay(String dayStr)
get Calendar By Day
Calendar calendar = Calendar.getInstance();
Date date = yyyyMMddFormat.parse(dayStr);
calendar.setTime(date);
return calendar;
longgetConfirmDateTimeOfDay(Date currentDate)
get Confirm Date Time Of Day
try {
    SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
    return sf.parse(sf.format(currentDate)).getTime() / 1000;
} catch (Exception e) {
    e.printStackTrace();
return -1;
StringgetCurDayZero()
get Cur Day Zero
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
return new SimpleDateFormat("yyyy-MM-dd 00:00:00").format(calendar.getTime());
FilegetDataFile(int tableId, Date day)
get Data File
String dateText = getDayText(day);
File tableDir = new File(logDir, Integer.toString(tableId));
File datafile = new File(tableDir, dateText + ".dat");
return datafile;
DategetDataTimeForwordDay(Date date, int dayNum)
get Data Time Forword Day
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, dayNum);
return cal.getTime();