Well I think I would use something like:

private static boolean today (DateTime dateTime)
{
   DateMight today = new DateMidnight();
   return today.equals(dateTime.toDateMidnight());
}

(I would certainly not use YearMonthDay as it is "replaced" with LocalDate)

On 9/24/07, Jeff White <[EMAIL PROTECTED]> wrote:
>
> Did you try
>
> private static boolean today (DateTime dateTime)
> {
>    YearMonthDay today = new YearMonthDay();
>    return dateTime.toYearMonthDay().equals(today);
> }
>
> jeff
>
> Ryan Propper wrote:
> > Hi all,
> >
> > What's the fastest and cleanest way of checking whether a DateTime
> > object occurred today?  Right now, I have the following, but I'm
> > wondering if there's something more efficient.
> >
> >   private static boolean today(DateTime dateTime) {
> >     DateTime now = new DateTime();
> >
> >     return (dateTime.getYear() == now.getYear() &&
> >             dateTime.getMonthOfYear() == now.getMonthOfYear() &&
> >             dateTime.getDayOfMonth() == now.getDayOfMonth());
> >   }
> >
> > Thanks!
> >
> > Ryan
> >
> >
> -------------------------------------------------------------------------
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2005.
> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > _______________________________________________
> > Joda-interest mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/joda-interest
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Joda-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/joda-interest
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to