Java Now compareWithNow_2(String t)

Here you can find the source of compareWithNow_2(String t)

Description

compare With No_

License

Apache License

Declaration

public static int compareWithNow_2(String t) 

Method Source Code

//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);
    }
}

Related

  1. calNow()
  2. compareDateWithNow(Date date1)
  3. formatNow()
  4. formatNow()
  5. formatNow()
  6. formatNow(String fmt)