According to laredotornado ??<laredotorn...@zipmail.com>:
I'm using Java 1.5. ??I have a java.util.Date object and I would like
to determine if it's date (i.e. year, month, and day) are greater
than (in the future) or equal to today's date (year, month, and day).
However, I don't care about any time component (hour, minute, second
...) when the comparison is taking place. ??What is the easiest way I
can determine this?
If you are in the UTC time zone (often called GMT too), then this is
simple. Use this:
?? ?? ?? ?? public static int dayCount(Date d)
?? ?? ?? ?? {
?? ?? ?? ?? ?? ?? ?? ?? return (int)(d.getTime() / 86400000L);
?? ?? ?? ?? }
which returns the date as an integral count of days since January 1st,
1970. You then just have to compare those day counts.
For other time zones, you will have to resort to Calendar and TimeZone.
Create a TimeZone instance for your time zone, then get a Calendar
instance (with Calendar.getInstance(TimeZone)), and use it to convert
your dates into years, months and days.
?? ?? ?? ?? --Thomas Pornin
Thanks. This is just the simple solution I was looking for. One follow
up . Why is the timezone important? If I know that both my Date objects