Android Utililty Methods Day in Month Get

List of utility methods to do Day in Month Get

Description

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

Method

StringgetStringDayOfMonth(Date date)
get String Day Of Month
SimpleDateFormat sdf = new SimpleDateFormat("dd");
return sdf.format(date);
StringgetFirstDayOfMonth(String format)
get First Day Of Month
String strDate = null;
try {
    Calendar c = new GregorianCalendar();
    SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(
            format);
    c.set(GregorianCalendar.DAY_OF_MONTH, 1);
    strDate = mSimpleDateFormat.format(c.getTime());
} catch (Exception e) {
...
StringgetFirstDayOfMonth(String format)
get First Day Of Month
String strDate = null;
try {
    Calendar c = new GregorianCalendar();
    SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(
            format);
    c.set(Calendar.DAY_OF_MONTH, 1);
    strDate = mSimpleDateFormat.format(c.getTime());
} catch (Exception e) {
...
StringgetLastDayOfMonth(String format)
get Last Day Of Month
String strDate = null;
try {
    Calendar c = new GregorianCalendar();
    SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(
            format);
    c.set(Calendar.DATE, 1);
    c.roll(Calendar.DATE, -1);
    strDate = mSimpleDateFormat.format(c.getTime());
...
StringgetLastDayOfMonth(String format)
get Last Day Of Month
String strDate = null;
try {
    Calendar c = new GregorianCalendar();
    SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(
            format);
    c.set(Calendar.DATE, 1);
    c.roll(Calendar.DATE, -1);
    strDate = mSimpleDateFormat.format(c.getTime());
...
DatefirstDayOfMonth(Date date)
first Day Of Month
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance()
        .getActualMinimum(Calendar.DAY_OF_MONTH));
cal.set(Calendar.HOUR_OF_DAY, Calendar.getInstance()
        .getActualMinimum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE,
        Calendar.getInstance().getActualMinimum(Calendar.MINUTE));
...
DatelastDayOfMonth(Date date)
last Day Of Month
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.DAY_OF_MONTH, Calendar.getInstance()
        .getActualMaximum(Calendar.DAY_OF_MONTH));
cal.set(Calendar.HOUR_OF_DAY, Calendar.getInstance()
        .getActualMaximum(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE,
        Calendar.getInstance().getActualMaximum(Calendar.MINUTE));
...
intmonthDays(int y, int m)
month Days
if ((lunarInfo[y - 1900] & (0x10000 >> m)) == 0)
    return 29;
else
    return 30;