Android Utililty Methods Date Today Get

List of utility methods to do Date Today Get

Description

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

Method

DategetDateToday()
get Date Today
Date curDate = new Date();
return curDate;
longgetSystemDate()
get System Date
Date date = new Date();
return date.getTime();
StringgetToday()
get Today
Date curDate = new Date();
SimpleDateFormat sdf;
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
today = sdf.format(curDate);
return today;
StringgetTodayDateString()
get Today Date String
Calendar now = Calendar.getInstance();
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH) + 1;
int day = now.get(Calendar.DAY_OF_MONTH);
String monthStr = String.valueOf(month);
String dayStr = String.valueOf(day);
if (month < 10) {
    monthStr = "0" + dayStr;
...
longgetTodayEndTime()
get Today End Time, "yyyy-MM-dd HH:mm"
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE_YYYY_MM_DD);
String strDate = sdf.format(date);
Date date2 = null;
try {
    date2 = sdf.parse(strDate);
    SimpleDateFormat sdf2 = new SimpleDateFormat(
            FORMAT_DATE_AND_TIME_YYYY_MM_DD_HH_MM);
...
longgetTodayStartTime()
get Today Start Time, "yyyy-MM-dd HH:mm"
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATE_YYYY_MM_DD);
String strDate = sdf.format(date);
Date date2 = null;
try {
    date2 = sdf.parse(strDate);
    SimpleDateFormat sdf2 = new SimpleDateFormat(
            FORMAT_DATE_AND_TIME_YYYY_MM_DD_HH_MM);
...
Datetoday()
today
return resetTime(new Date());
DatetodayWithHour()
today With Hour
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
int hour = cal.get(Calendar.HOUR_OF_DAY) + 1;
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
...
StringgetDate()
get Date
SimpleDateFormat fromat = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.get(Calendar.YEAR);
c.get(Calendar.MONTH + 1);
c.get(Calendar.DAY_OF_MONTH);
String time = fromat.format(c.getInstance().getTime());
return time;
StringgetCurrentDate()
get Current Date
Date date = new Date(System.currentTimeMillis());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String text = sdf.format(date);
return text;