commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 26922] - [lang] public static boolean DateUtils.equals(Date dt1, Date dt2) ?
Date Mon, 16 Feb 2004 09:31:34 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26922>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26922

[lang] public static boolean DateUtils.equals(Date dt1, Date dt2) ?





------- Additional Comments From mpatron@influe.com  2004-02-16 09:31 -------
Yes, I agree with you. And I propose the code to do this :

    /**
     * <p>Compares two Dates, returning <code>true</code> if they are equal.</p>
     *
     * <p><code>null</code>s are handled without exceptions. Two 
<code>null</code>
     * references are considered to be equal.</p>
     *
     * <pre>
     * long now = System.currentTimeMillis();
     * java.util.Date date = new java.util.Date(now);
     * java.sql.Timestamp timestamp = new java.sql.Timestamp(now);
     * DateUtils.equals(null, null)   = true
     * DateUtils.equals(null, date)  = false
     * DateUtils.equals(date, null)  = false
     * DateUtils.equals(date, date) = true
     * DateUtils.equals(date, timestamp) = true
     * </pre>
     *
     * @see java.util.Date#equals(Object)
     * @param dt1  the first Date, may be null
     * @param dt2  the second Date, may be null
     * @return <code>true</code> if the Dates are equal or both 
<code>null</code>
     */
	  public static boolean equals(Date dt1, Date dt2) {
	      return (dt1 == null ? dt2 == null : dt1.getTime() == dt2.getTime
());
	  }

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message