🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1156

Re: How to calc a diffence between two dates?

#1156
From: Gillmer J. Derge [TeamB]
Date: Thu, 30 May 2002 16:09
18 lines
1523 bytes
"Edilmar Alves" <Edilmar@InterSite.com.br> wrote in message
news:3CF64A39.3090904@InterSite.com.br...
> Then, I would like to do something like this:
>
>     GregorianCalendar firstdate = new GregorianCalendar(Year1, Mouth1,
> Day1);
>     GregorianCalendar lastdate = new GregorianCalendar(Year2, Mouth2,
Day2);
>     int numberofdays = lastdate - firstdate; // THIS LINE DOESN'T WORK

You can get the time in milliseconds since [some date] and then convert
milliseconds to days.

  long numberOfDays = (lastdate.getTimeInMillis() -
firstdate.getTimeInMillis()) / (1000 * 60 * 60 * 24);

--
Gillmer J. Derge [TeamB]
Technical Details
Message-ID: <3cf64ec9$1_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!cox.net!newspeer1-gui.server.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3CF64A39.3090904@InterSite.com.br>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,62cdda374b9be1e3,start
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2002-05-30 09:11:46 PST
From: "Gillmer J. Derge [TeamB]" <spam@gillmerderge.com>
Newsgroups: borland.public.jbuilder.java.api
References: <3CF64A39.3090904@InterSite.com.br>
Subject: Re: How to calc a diffence between two dates?
Date: Thu, 30 May 2002 12:09:45 -0400
Lines: 21
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 24.58.130.24
Message-ID: <3cf64ec9$1_1@dnews>
X-Trace: dnews 1022774985 24.58.130.24 (30 May 2002 09:09:45 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!cox.net!newspeer1-gui.server.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!dnews