You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "David J. M. Karlsen (JIRA)" <ji...@apache.org> on 2006/10/29 17:36:16 UTC
[jira] Created: (LANG-291) Null-safe comparison methods for finding
most recent / least recent dates.
Null-safe comparison methods for finding most recent / least recent dates.
--------------------------------------------------------------------------
Key: LANG-291
URL: http://issues.apache.org/jira/browse/LANG-291
Project: Commons Lang
Issue Type: Improvement
Environment: N/A
Reporter: David J. M. Karlsen
/**
* <p>
* Null-safe date comparison.
* Returnes the most recent date if date1 and date2 is non-null.
* If one of the dates are null, the non-null will be returned.
* If both are null, null will be returned.
* </p>
* @param date1
* @param date2
* @return
*/
public static Date mostRecent( Date date1, Date date2 )
/**
* <p>
* Null-safe date comparison.
* Returnes the least recent (oldest) date if date1 and date2 is non-null.
* If one of the dates are null, the non-null will be returned.
* If both are null, null will be returned.
* </p>
* @param date1
* @param date2
* @return
*/
public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Resolved: (LANG-291) Null-safe comparison methods for
finding most recent / least recent dates.
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-291?page=all ]
Henri Yandell resolved LANG-291.
--------------------------------
Fix Version/s: 2.3
(was: 3.0)
Resolution: Fixed
Bit sooner than I thought:
svn ci -m "Applying max/min for Comparables as supplied by David Karlsen in LANG-291" src/
Sending src/java/org/apache/commons/lang/ObjectUtils.java
Sending src/test/org/apache/commons/lang/ObjectUtilsTest.java
Transmitting file data ..
Committed revision 475113.
> Null-safe comparison methods for finding most recent / least recent dates.
> --------------------------------------------------------------------------
>
> Key: LANG-291
> URL: http://issues.apache.org/jira/browse/LANG-291
> Project: Commons Lang
> Issue Type: Improvement
> Environment: N/A
> Reporter: David J. M. Karlsen
> Fix For: 2.3
>
> Attachments: DateUtils-patch-rev468924.txt, ObjectUtils-patch-rev470351.txt
>
>
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the most recent date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date mostRecent( Date date1, Date date2 )
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the least recent (oldest) date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-291) Null-safe comparison methods for finding
most recent / least recent dates.
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-291?page=all ]
Henri Yandell updated LANG-291:
-------------------------------
Fix Version/s: 3.0
> Null-safe comparison methods for finding most recent / least recent dates.
> --------------------------------------------------------------------------
>
> Key: LANG-291
> URL: http://issues.apache.org/jira/browse/LANG-291
> Project: Commons Lang
> Issue Type: Improvement
> Environment: N/A
> Reporter: David J. M. Karlsen
> Fix For: 3.0
>
> Attachments: DateUtils-patch-rev468924.txt
>
>
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the most recent date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date mostRecent( Date date1, Date date2 )
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the least recent (oldest) date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-291) Null-safe comparison methods for finding
most recent / least recent dates.
Posted by "David J. M. Karlsen (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-291?page=all ]
David J. M. Karlsen updated LANG-291:
-------------------------------------
Attachment: DateUtils-patch-rev468924.txt
Patch includes the two implementations and tests
> Null-safe comparison methods for finding most recent / least recent dates.
> --------------------------------------------------------------------------
>
> Key: LANG-291
> URL: http://issues.apache.org/jira/browse/LANG-291
> Project: Commons Lang
> Issue Type: Improvement
> Environment: N/A
> Reporter: David J. M. Karlsen
> Attachments: DateUtils-patch-rev468924.txt
>
>
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the most recent date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date mostRecent( Date date1, Date date2 )
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the least recent (oldest) date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (LANG-291) Null-safe comparison methods for
finding most recent / least recent dates.
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-291?page=comments#action_12445736 ]
Henri Yandell commented on LANG-291:
------------------------------------
It seems to me that these are more specific cases of Comparable.compareTo. Rather than the above we could have:
ObjectUtils.lesser(Comparable c1, Comparable c2)
ObjectUtils.greater(Comparable c1, Comparable c2)
ObjectUtils.compareTo(Comparable c1, Comparable c2) [see: http://mail-archives.apache.org/mod_mbox/jakarta-commons-user/200602.mbox/%3Cdteipl$rnv$1@sea.gmane.org%3E]
What do you think?
> Null-safe comparison methods for finding most recent / least recent dates.
> --------------------------------------------------------------------------
>
> Key: LANG-291
> URL: http://issues.apache.org/jira/browse/LANG-291
> Project: Commons Lang
> Issue Type: Improvement
> Environment: N/A
> Reporter: David J. M. Karlsen
> Attachments: DateUtils-patch-rev468924.txt
>
>
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the most recent date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date mostRecent( Date date1, Date date2 )
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the least recent (oldest) date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (LANG-291) Null-safe comparison methods for
finding most recent / least recent dates.
Posted by "David J. M. Karlsen (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-291?page=comments#action_12446027 ]
David J. M. Karlsen commented on LANG-291:
------------------------------------------
Absolutely - good idea! Didn't pass my mind - I'll go ahead and create a patch for this.
> Null-safe comparison methods for finding most recent / least recent dates.
> --------------------------------------------------------------------------
>
> Key: LANG-291
> URL: http://issues.apache.org/jira/browse/LANG-291
> Project: Commons Lang
> Issue Type: Improvement
> Environment: N/A
> Reporter: David J. M. Karlsen
> Attachments: DateUtils-patch-rev468924.txt
>
>
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the most recent date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date mostRecent( Date date1, Date date2 )
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the least recent (oldest) date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (LANG-291) Null-safe comparison methods for
finding most recent / least recent dates.
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-291?page=comments#action_12449906 ]
Henri Yandell commented on LANG-291:
------------------------------------
Quite likely - the 2.3 Enum issues haven't played out as I thought they would - very little change to Lang; so I'm just chugging along and adding things that won't break backwards compat.
I figured I shouldn't be releasing 2.3 too soon, so BeanUtils, DbUtils and Discovery have been jumping ahead in my queue. I'll go ahead and look at applying this if no one else does soon.
> Null-safe comparison methods for finding most recent / least recent dates.
> --------------------------------------------------------------------------
>
> Key: LANG-291
> URL: http://issues.apache.org/jira/browse/LANG-291
> Project: Commons Lang
> Issue Type: Improvement
> Environment: N/A
> Reporter: David J. M. Karlsen
> Fix For: 3.0
>
> Attachments: DateUtils-patch-rev468924.txt, ObjectUtils-patch-rev470351.txt
>
>
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the most recent date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date mostRecent( Date date1, Date date2 )
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the least recent (oldest) date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (LANG-291) Null-safe comparison methods for
finding most recent / least recent dates.
Posted by "David J. M. Karlsen (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-291?page=comments#action_12449413 ]
David J. M. Karlsen commented on LANG-291:
------------------------------------------
Any chance this could be scheduled for the upcoming 2.3 release as it contains tests as well?
> Null-safe comparison methods for finding most recent / least recent dates.
> --------------------------------------------------------------------------
>
> Key: LANG-291
> URL: http://issues.apache.org/jira/browse/LANG-291
> Project: Commons Lang
> Issue Type: Improvement
> Environment: N/A
> Reporter: David J. M. Karlsen
> Fix For: 3.0
>
> Attachments: DateUtils-patch-rev468924.txt, ObjectUtils-patch-rev470351.txt
>
>
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the most recent date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date mostRecent( Date date1, Date date2 )
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the least recent (oldest) date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (LANG-291) Null-safe comparison methods for
finding most recent / least recent dates.
Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-291?page=comments#action_12446052 ]
Gary Gregory commented on LANG-291:
-----------------------------------
How about following the naming from Math.min() and Math.max():
public static Date min(Date date1, Date date2);
public static Date max(Date date1, Date date2);
Alternatively, when I read 'Returnes [sic] the least recent (oldest)", why not call the methods oldest() and newest()
> Null-safe comparison methods for finding most recent / least recent dates.
> --------------------------------------------------------------------------
>
> Key: LANG-291
> URL: http://issues.apache.org/jira/browse/LANG-291
> Project: Commons Lang
> Issue Type: Improvement
> Environment: N/A
> Reporter: David J. M. Karlsen
> Fix For: 3.0
>
> Attachments: DateUtils-patch-rev468924.txt
>
>
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the most recent date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date mostRecent( Date date1, Date date2 )
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the least recent (oldest) date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (LANG-291) Null-safe comparison methods for finding
most recent / least recent dates.
Posted by "David J. M. Karlsen (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/LANG-291?page=all ]
David J. M. Karlsen updated LANG-291:
-------------------------------------
Attachment: ObjectUtils-patch-rev470351.txt
PLease delete the DateUtils patch, and use this more general patch with max(Comparable, Comparable) an min(Comparable, Comparable) methods in ObjectUtils.
A compareTo( Comparable, Comparable ) is left out, as this would violate Java protocol, see
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Comparable.html
"Note that null is not an instance of any class, and e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false."
> Null-safe comparison methods for finding most recent / least recent dates.
> --------------------------------------------------------------------------
>
> Key: LANG-291
> URL: http://issues.apache.org/jira/browse/LANG-291
> Project: Commons Lang
> Issue Type: Improvement
> Environment: N/A
> Reporter: David J. M. Karlsen
> Fix For: 3.0
>
> Attachments: DateUtils-patch-rev468924.txt, ObjectUtils-patch-rev470351.txt
>
>
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the most recent date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date mostRecent( Date date1, Date date2 )
> /**
> * <p>
> * Null-safe date comparison.
> * Returnes the least recent (oldest) date if date1 and date2 is non-null.
> * If one of the dates are null, the non-null will be returned.
> * If both are null, null will be returned.
> * </p>
> * @param date1
> * @param date2
> * @return
> */
> public static Date leastRecent( Date date1, Date date2 )
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org