Java Timestamp Now isCurrentDataByStartdataAndEnddata(Timestamp startDate, Timestamp endDate)

Here you can find the source of isCurrentDataByStartdataAndEnddata(Timestamp startDate, Timestamp endDate)

Description

the method's result was used decsion isCurrentDate by startDate and endDate

License

Open Source License

Parameter

Parameter Description
startDate is a specifically Timestamp
endDate is a specifically Timestamp

Declaration

public static boolean isCurrentDataByStartdataAndEnddata(Timestamp startDate, Timestamp endDate) 

Method Source Code

//package com.java2s;
/*//from w  w  w  .  java  2 s.co  m
* @(#)Utility.java
*
* Copyright (c) 2003 DCIVision Ltd
* All rights reserved.
*
* This software is the confidential and proprietary information of DCIVision
* Ltd ("Confidential Information").  You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the license
* agreement you entered into with DCIVision Ltd.
 */

import java.sql.Timestamp;

public class Main {
    /**
     * the method's result was used decsion isCurrentDate by startDate and endDate
     * 
     * @param startDate is a specifically Timestamp
     * @param endDate is a specifically Timestamp
     * @return 
     */
    public static boolean isCurrentDataByStartdataAndEnddata(Timestamp startDate, Timestamp endDate) {
        boolean result = false;
        Timestamp currentDate = getCurrentTimestamp();
        if (endDate == null) {
            if (currentDate.compareTo(startDate) >= 0) {
                result = true;
            }
        } else {
            if ((currentDate.compareTo(startDate)) >= 0 && (currentDate.compareTo(endDate)) <= 0) {
                result = true;
            }
        }
        return result;
    }

    /**
     * getCurrentTimestamp
     *
     * Returns current time in Timestamp object.
     *
     * @return  Timestamp object which representing the current time.
     */
    public static java.sql.Timestamp getCurrentTimestamp() {
        java.util.Calendar tmp = java.util.Calendar.getInstance();
        tmp.clear(java.util.Calendar.MILLISECOND);
        return (new java.sql.Timestamp(tmp.getTime().getTime()));
    }
}

Related

  1. getTimestamp()
  2. getTimestamp()
  3. getTimestamp()
  4. getTimeStamp()
  5. getTimestamp()
  6. nowTimestamp()
  7. nowTimestamp()
  8. nowTimestamp()
  9. nowTimestamp()