Java tutorial
//package com.java2s; import android.support.annotation.Nullable; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /** * @param time time stamp * @param formatType time conversion format * @return is it the day */ public static boolean isToday(long time, @Nullable String formatType) { if (time == 0) { long currentTime = new Date().getTime(); time = currentTime - 86400000; } if (formatType == null) { formatType = "yyyy-MM-dd"; } Date dateOld = new Date(time); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(formatType, Locale.getDefault()); if (simpleDateFormat.format(dateOld).equals(simpleDateFormat.format(new Date()))) { return true; } else { return false; } } }