Find the date is Current date or not – Android

SimpleDateFormat sdf = new SimpleDateFormat(

“dd-MM-yyyy HH:mm:ss”);

Date date = sdf.parse(date_string);

Calendar calendar = Calendar.getInstance();

calendar.setTime(date);

calendar.set(calendar.get(calendar.YEAR), calendar.get(calendar.MONTH),

calendar.get(calendar.DATE), calendar.get(calendar.HOUR),

calendar.get(calendar.MINUTE), calendar.get(calendar.SECOND));

long startTime = calendar.getTimeInMillis();

Boolean isCurrnetDate =  DateUtils.isToday(startTime);

Advertisements