List of utility methods to do Day Get
long | getDayStartTime(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) { ... |
Date | lastDay(Date date) last Day Calendar calendar = convert(date);
calendar.set(Calendar.DATE,
calendar.getActualMaximum(Calendar.DATE));
return calendar.getTime();
|
Date | firstDay(Date date) first Day Calendar calendar = convert(date);
calendar.set(Calendar.DATE, 1);
return calendar.getTime();
|
int | getDay(long dateTimeMillis) get Day SimpleDateFormat format = new SimpleDateFormat("dd"); StringBuilder dateString = new StringBuilder( format.format(dateTimeMillis)); return Integer.parseInt(dateString.toString()); |
String | getDaySelect(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 ... |
String | getDaySelect(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 ... |
String | getCurrentDay() get Current Day return getFormatCurrentTime("dd"); |
String | getSmartDateString(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; ... |
String | getWeatherDateStr(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; |