Created
December 26, 2011 02:47
-
-
Save e2kaneko/1520439 to your computer and use it in GitHub Desktop.
Java JavaのDate(java.util.Date)を利用したbetweenの実装
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 明示的な実装 | |
| public boolean between(Date date, Date minDate, Date maxDate){ | |
| return date.after(minDate) && date.before(maxDate); | |
| } | |
| // 合理的(?)な実装 | |
| public boolean between(Date date, Date minDate, Date maxDate){ | |
| return minDate.compareTo(date) * date.compareTo(maxDate) > 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment