Java Time Passed isExpire(String strTime, String strExpiredTime)

Here you can find the source of isExpire(String strTime, String strExpiredTime)

Description

is Expire

License

Open Source License

Declaration

public static boolean isExpire(String strTime, String strExpiredTime) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.TimeZone;

public class Main {
    static public final String FORMAT_NORMAL = "yyyy-MM-dd HH:mm:ss";

    public static boolean isExpire(String strTime, String strExpiredTime) {
        Date time = parse(strTime, FORMAT_NORMAL);
        Date expiredTime = parse(strExpiredTime, FORMAT_NORMAL);

        return (time.compareTo(expiredTime) >= 0);
    }/*from w w w. j  a v a  2s . co m*/

    public static Date parse(String str, String format) {
        try {
            SimpleDateFormat sf = new SimpleDateFormat(format);
            sf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
            return sf.parse(str);
        } catch (ParseException e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. isConfilct(String begintimeOne, String endtimeOne, String begintimeTwo, String endtimeTwo)
  2. isInBetweenTimes(String startTime, String endTime)
  3. isLimitTimeScope(String minTime, String maxTime)
  4. printTimeElapsed(long starttime)