package com.sipai.jspatrol.utils;

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

/**
 * created by lvliming on 2019/8/1
 */
public class DateFormatUtils {
    public static String DateFormatDayString(String st){
        String dateString = "";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date date = simpleDateFormat.parse(st);
            dateString = simpleDateFormat.format(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return dateString;
    }
    public static String DateFormatMinString(String st){
        String dateString = "";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        try {
            Date date = simpleDateFormat.parse(st);
            dateString = simpleDateFormat.format(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return dateString;
    }

    public static String DateFormatMinStringPL(long st){
        String dateString = "";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        dateString = simpleDateFormat.format(st);
        return dateString;
    }

    public static long pareSec(String time){

        SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

        long s=0;

        try {

            s=sim.parse(time).getTime();

        } catch (ParseException e) {

// TODO Auto-generated catch block

            e.printStackTrace();

        }

        return s;

    }

}
