CustomStringUtils.java 1.09 KB
package com.bsth.data.utils;

import org.apache.commons.lang3.StringUtils;

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

/**
 * Created by panzhao on 2017/7/10.
 */
public class CustomStringUtils {

    public static boolean equals(String s1, String s2){
        if(s1 == null){
            if(StringUtils.isNotEmpty(s2))
                return false;
            else
                return true;
        }
        return s1.equals(s2);
    }

    public static String maxEndTime(String sStr, String eStr, int space) throws ParseException {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            long st = sdf.parse(sStr).getTime();
            long et = sdf.parse(eStr).getTime();
            long dayTime = 24 * 60 * 60 * 1000;
            long spaceTime = dayTime * space;

            if (et - st > spaceTime) {
                eStr = sdf.format(new Date(st + spaceTime));
            }
        } catch (Exception e) {
            throw e;
        }
        return eStr;
    }
}