package com.qimai.android.fetch;

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

/**
 * Explain：
 * Created on 2020/8/31.
 *
 * @author zhangshenglong
 */
public class TimeUtil {

    /**
     * 判断结束时间是否大于开始时间
     *
     * @param start_time
     * @param end_time
     * @return
     */
    public static boolean timeCompare(String start_time, String end_time) {
        //格式化时间
        SimpleDateFormat CurrentTime = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
//        String date1="2015-01-25 09:12:09";
//        String date2="2015-01-29 09:12:11";
        try {
            Date beginTime = CurrentTime.parse(start_time);
            Date endTime = CurrentTime.parse(end_time);
            //判断是否大于两天
            if (endTime.getTime() < beginTime.getTime()) {
                return false;
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }

    public static String getNowTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");
        Date curDate = new Date(System.currentTimeMillis());
        return formatter.format(curDate);
    }


}
