Android Utililty Methods Day Get

List of utility methods to do Day Get

Description

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

Method

longgetDayStartTime(long time)
get Day Start Time
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(time);
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
String strDay = sf.format(cal.getTime());
long result;
try {
    result = sf.parse(strDay).getTime();
} catch (ParseException e) {
...
DatelastDay(Date date)
last Day
Calendar calendar = convert(date);
calendar.set(Calendar.DATE,
        calendar.getActualMaximum(Calendar.DATE));
return calendar.getTime();
DatefirstDay(Date date)
first Day
Calendar calendar = convert(date);
calendar.set(Calendar.DATE, 1);
return calendar.getTime();
intgetDay(long dateTimeMillis)
get Day
SimpleDateFormat format = new SimpleDateFormat("dd");
StringBuilder dateString = new StringBuilder(
        format.format(dateTimeMillis));
return Integer.parseInt(dateString.toString());
StringgetDaySelect(String selectName, String value, boolean hasBlank)
get Day Select
StringBuffer sb = new StringBuffer("");
sb.append("<select name=\"" + selectName + "\">");
if (hasBlank) {
    sb.append("<option value=\"\"></option>");
for (int i = 1; i <= 31; i++) {
    if (!value.trim().equals("") && i == Integer.parseInt(value)) {
        sb.append("<option value=\"" + i + "\" selected>" + i
...
StringgetDaySelect(String selectName, String value, boolean hasBlank, String js)
get Day Select
StringBuffer sb = new StringBuffer("");
sb.append("<select name=\"" + selectName + "\" " + js + ">");
if (hasBlank) {
    sb.append("<option value=\"\"></option>");
for (int i = 1; i <= 31; i++) {
    if (!value.trim().equals("") && i == Integer.parseInt(value)) {
        sb.append("<option value=\"" + i + "\" selected>" + i
...
StringgetCurrentDay()
get Current Day
return getFormatCurrentTime("dd");
StringgetSmartDateString(long time, String extString, String zeroDayString)
get Smart Date String
long theTime = getDayStartTime(time);
long nowTime = getDayStartTime(System.currentTimeMillis());
long moreTime = nowTime - theTime;
if (moreTime <= 0L) {
    return zeroDayString;
if (moreTime < oneDay * 7) {
    return (moreTime / oneDay) + " " + extString;
...
StringgetWeatherDateStr(int day)
get Weather Date Str
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat(
        WEATHER_DATE_FORMAT);
if (day == 0) {
    return dateFormat.format(calendar.getTime());
} else {
    calendar.roll(Calendar.DAY_OF_YEAR, day);
    return dateFormat.format(calendar.getTime());
...
String[]getArrayDiffDays(String startDate, String endDate)
get Array Diff Days
int LEN = 0;
if (startDate.equals(endDate)) {
    return new String[] { startDate };
Date sdate = null;
if (startDate.indexOf("/") > 0 && endDate.indexOf("/") > 0) {
    sdate = getDateObj(startDate, "/");
if (startDate.indexOf("-") > 0 && endDate.indexOf("-") > 0) {
    sdate = getDateObj(startDate, "-");
LEN = getDiffDays(startDate, endDate);
String[] dateResult = new String[LEN + 1];
dateResult[0] = startDate;
for (int i = 1; i < LEN + 1; i++) {
    if (startDate.indexOf("/") > 0 && endDate.indexOf("/") > 0) {
        dateResult[i] = getFormatDateTime(getDateAdd(sdate, i),
                "yyyy/MM/dd");
    if (startDate.indexOf("-") > 0 && endDate.indexOf("-") > 0) {
        dateResult[i] = getFormatDateTime(getDateAdd(sdate, i),
                "yyyy-MM-dd");
return dateResult;