Android examples for java.util:Today
compare Date and today's date By Day
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static int compareToDay(String datestring) { Calendar today = Calendar.getInstance(); Calendar moday = stringToCalendar(datestring); return today.compareTo(moday); }/*w ww . j ava 2s .c o m*/ public static Calendar stringToCalendar(String datestring) { Calendar calendar = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); try { Date date = df.parse(datestring); calendar.setTime(date); } catch (Exception e) { e.printStackTrace(); } return calendar; } }