Here you can find the source of compareWithNow_2(String t)
public static int compareWithNow_2(String t)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static final String DATE_FORMAT_2 = "yyyy-MM-dd"; public static int compareWithNow_2(String t) { SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_2); Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); try {//from w w w.j a va 2 s.co m c1.setTime(formatter.parse(t)); c2.setTime(new Date()); } catch (ParseException e) { e.printStackTrace(); } return c1.compareTo(c2); } }