Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.DateFormat;

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

import java.util.Date;

public class Main {
    /**
     * The end of the rush to buy whether
     * 
     * @param endTime
     * @param currentTime
     * @return Has been completed
     */
    public static boolean isOver(String endTime, String currentTime) {
        Date current = null;
        Date end = null;
        try {
            DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            current = format.parse(currentTime);
            end = format.parse(endTime);
        } catch (IllegalArgumentException e) {
            return false;
        } catch (ParseException e) {
            return false;
        }
        if (current != null && end != null) {
            return current.after(end);
        }
        return false;
    }
}