Java Utililty Methods Day

List of utility methods to do Day

Description

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

Method

longgetDaysforYear()
get Daysfor Year
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int year = Integer.valueOf(sdf.format(d).substring(0, 4));
long count = (year % 400 == 0) || (year % 100 != 0) && (year % 4 == 0) ? 366 : 365;
return count;
intgetDaysFrom2Dates(Calendar calendar1, Calendar calendar2)
get Days From Dates
return (int) (Math.abs(calendar1.getTimeInMillis() - calendar2.getTimeInMillis()) / MILLISECOND_DAY);
StringgetDaysLater(int day)
get Days Later
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, day);
return formatDate(calendar.getTime(), "yyyy-MM-dd") + " 00:00:00";
HashtablegetDaysMonthYear(Date date)
get Days Month Year
Hashtable<String, Object> _value = new Hashtable<String, Object>();
Calendar _calendar = Calendar.getInstance();
_calendar.setTime(date);
int _days = _calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
String _month = getMonth(date);
String _year = getYear(date);
_value.put("days", _days);
_value.put("month", _month);
...
longgetDaysOfDates(Date first, Date second)
get Days Of Dates
Date d1 = getFormatDateTime(getFormatDate(first), DATE_FORMAT);
Date d2 = getFormatDateTime(getFormatDate(second), DATE_FORMAT);
long mils = d1.getTime() - d2.getTime();
return mils / (TIME_DAY_MILLISECOND);
intgetdaysslice(String startdate, String enddate)
getdaysslice
if (startdate == null || "".equals(startdate.trim()))
    return 0;
if (enddate == null || "".equals(enddate.trim()))
    return 0;
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date start = null;
java.util.Date end = null;
try {
...
StringgetDayStr(int i, String formatStr)
get Day Str
GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
gc.setTime(new Date());
gc.add(Calendar.DATE, i);
SimpleDateFormat formatter = new SimpleDateFormat(formatStr);
String dateString = formatter.format(gc.getTime());
return dateString;
StringgetDayStringOfDate(Date date)
get Day String Of Date
DateFormat date_format = new SimpleDateFormat("yyyyMMdd");
return date_format.format(date);
StringgetDayText(Date day)
get Day Text
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String dateText = dateFormat.format(day);
return dateText;
StringgetDayTime_End()
get Day Tim End
String v_DateStr = SDF_TIME.format(new java.util.Date(System.currentTimeMillis() - 5400000));
String[] v_DateStrArr = v_DateStr.split("\\:");
int v_Min_Int = (Integer.parseInt(v_DateStrArr[1]) / 15) * 15;
String v_Min_Str = v_Min_Int < 10 ? v_Min_Int + "0" : String.valueOf(v_Min_Int);
return v_DateStrArr[0] + ":" + v_Min_Str + ":00";