package com.bxzk.afxj.util;

import android.util.Log;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by shuj on 2019/1/9
 */
public class dealDateFormatUtils {
    /**
     * 计算两个日期的相隔天数
     * @return
     */
    public static int daysBetween(String oldDate){
        Date  date=null;
        try {
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
            date = df.parse(oldDate);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date());
        long time1 = cal.getTimeInMillis()/100;
//        cal.setTime(date.getTime());
        long time2 = date.getTime()/100;
        long between_days=(time2-time1)/(1000*3600*24);

        Log.i(time1+"",time2+"");
        return Integer.parseInt(String.valueOf(between_days));
    }
}
