Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: how to compare date and get latest one Date: Fri, 14 Mar 2014 21:20:21 +0000 (UTC) Organization: A noiseless patient Spider Lines: 29 Message-ID: References: <374d2575-df01-45de-8267-4c9b579e56be@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 14 Mar 2014 21:20:21 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="28760"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18tF28XTXzuaTWz9WfHivi1v6Ih0PsKAdQ=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:Mzj0jmb08G/X3QeKS9308WJyt2g= Xref: csiph.com comp.lang.java.programmer:27764 On Thu, 13 Mar 2014 23:42:54 -0700, Roedy Green wrote: > On Thu, 13 Mar 2014 08:16:32 -0700 (PDT), Navneet Mathpal > wrote, quoted or indirectly quoted someone > who said : > >>For insertion of time i am using Date date=new Date(); > > don't Dates implement Comparable? > > I don't know about Spring. Give or take a method or two java.util.Date and java.sql.Date are effectively the same; java.sql.Date is an extension of java.sql.date as is clearly stated in the standard class library documentation. IOW, both hold dates as milliseconds since January 1, 1970 00:00:00.000 GMT, which is both the UNIX base date and the SQL Standard base date. IOW you can do simple comparisons by using the methods defined in java.util.Date, but for anything more complex than that I use the methods in java.date.GregorianCalendar and I use java.textSimpleDateFormat for formatting and parsing date strings, i.e. all conversions between Date and String objects. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |