Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Tech > [JAVA] Differenza fra date
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[JAVA] Differenza fra date

Come calcolo la differanza fra due date?
Quello che voglio ottenere è una cosa di questo tipo:

a) 05/04/2003 00.10
b) 10/03/2003 12.00

a - b = "Sono trascorsi X gioni Y ore Z minuti dalla data b"

grazie!

__________________
http://www.twitter.com/0m4r

05-04-2003 23:10
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Joda
.grande:maestro.

User info:
Registered: Mar 2003
Posts: 1126 (0.14 al dì)
Location: Milano
Corso: Dottore in Informatica
Anno: Primo TICOM
Time Online: 9 Days, 23:17:40 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

omar , se non ricordo male , dovrebbe esister una funzione datediff , che calcola la diffrenza fra due date

__________________
Homepage personale (English version)
c/o segreteria didattica via comelico

05-04-2003 23:44
Click Here to See the Profile for Joda Click Here to See the Blog of Joda Click here to Send Joda a Private Message Visit Joda's homepage! Find more posts by Joda Add Joda to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Joda
omar , se non ricordo male , dovrebbe esister una funzione datediff , che calcola la diffrenza fra due date


io l'ho cercata nella documentazione di java ma non sono riuscito a trovarla... ;(

__________________
http://www.twitter.com/0m4r

06-04-2003 09:37
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
recoil
dsy adminz

User info:
Registered: Mar 2002
Posts: 4454 (0.53 al dì)
Location: Milano / Erba
Corso: TICOM
Anno: laureato
Time Online: 61 Days, 16:17:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

il metodo getTime della classe Date ti restituisce un intero, da qui fai la differenza e poi mi sembra che c'è un oggetto che riesce a ricostruirti una data a partire da quel numero che hai ottenuto.

cerca Calendar, DateFormat e Data

__________________
Sono sempre alla ricerca di curriculum interessanti da segnalare alle società con cui ho contatti. Info in pm

06-04-2003 11:42
Click Here to See the Profile for recoil Click here to Send recoil a Private Message Visit recoil's homepage! Find more posts by recoil Add recoil to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by recoil
il metodo getTime della classe Date ti restituisce un intero, da qui fai la differenza e poi mi sembra che c'è un oggetto che riesce a ricostruirti una data a partire da quel numero che hai ottenuto.

cerca Calendar, DateFormat e Data


questo lo so, ma quello che voglio avere io non è una nuova data ma un gap fra date...
col metodo che mi indichi tu ho gia provato, ma non mi sembra di ottenere cio che volgio...
cmq grazie del suggerimento

__________________
http://www.twitter.com/0m4r

06-04-2003 12:39
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Jerzat
ex-milanese

User info:
Registered: Nov 2002
Posts: 59 (0.01 al dì)
Location: Weekdays Milano - Weekend Sondrio
Corso: Informatica
Anno: Primo
Time Online: 14:26:36 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

scriviti un metodo che lo faccia...
A meno che l'oggetto data non sia qualcosa di astronomicamente complesso.

__________________
Jerzat

INSUTANTO MYUUJIKKU!
+1!

06-04-2003 22:33
Click Here to See the Profile for Jerzat Click here to Send Jerzat a Private Message Visit Jerzat's homepage! Find more posts by Jerzat Add Jerzat to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ecco...se ci fossi riuscito a scrivere due righe di codice decente non avrei postato qui no?
cmq grazie del suggerimento.

__________________
http://www.twitter.com/0m4r

07-04-2003 08:57
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Jerzat
ex-milanese

User info:
Registered: Nov 2002
Posts: 59 (0.01 al dì)
Location: Weekdays Milano - Weekend Sondrio
Corso: Informatica
Anno: Primo
Time Online: 14:26:36 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

sorry :(

__________________
Jerzat

INSUTANTO MYUUJIKKU!
+1!

07-04-2003 15:13
Click Here to See the Profile for Jerzat Click here to Send Jerzat a Private Message Visit Jerzat's homepage! Find more posts by Jerzat Add Jerzat to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lorenzo
...ma anche no.

User info:
Registered: Jun 2002
Posts: 3149 (0.38 al dì)
Location: Milano
Corso: F49
Anno: 00000011
Time Online: 49 Days, 1:47:46 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Non sono un esperto di Java™, ma...
Di solito (in molti linguaggi) gli interi associati alle date rappresentano il numero di secondi trascorsi dalla mezzanotte del 01/01/70 fino a quel momento.
Se fai la differenza tra i due interi quindi ottieni i secondi di differenza tra le due date.
Dividi la cifra per 60*60*24 e ottieni la differenza in giorni.

__________________
Non ti laureare, continua a cazzeggiare!

"È tutta merda..." - clod81

07-04-2003 15:26
Click Here to See the Profile for lorenzo Click Here to See the Blog of lorenzo Click here to Send lorenzo a Private Message Visit lorenzo's homepage! Find more posts by lorenzo Add lorenzo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by lorenzo
Non sono un esperto di Java™, ma...
Di solito (in molti linguaggi) gli interi associati alle date rappresentano il numero di secondi trascorsi dalla mezzanotte del 01/01/70 fino a quel momento.
Se fai la differenza tra i due interi quindi ottieni i secondi di differenza tra le due date.
Dividi la cifra per 60*60*24 e ottieni la differenza in giorni.


grazie anche a te, ma questo lo so...
quello che voglio ottenere però non è solo la differenza in giorni ma in giorno ore minuti dal giorno ora minuto X....

__________________
http://www.twitter.com/0m4r

07-04-2003 17:19
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lorenzo
...ma anche no.

User info:
Registered: Jun 2002
Posts: 3149 (0.38 al dì)
Location: Milano
Corso: F49
Anno: 00000011
Time Online: 49 Days, 1:47:46 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Facciamo che secs contiene il numero di secondi di differenza tra le due date.

Prima calcoli la differenza in giorni, poi col resto la differenza in ore, e poi in minuti.

code:
days = secs / 86400 secs = secs % 86400 hours = secs / 3600 secs = secs % 3600 mins = secs / 60 secs = secs %60

__________________
Non ti laureare, continua a cazzeggiare!

"È tutta merda..." - clod81

07-04-2003 18:27
Click Here to See the Profile for lorenzo Click Here to See the Blog of lorenzo Click here to Send lorenzo a Private Message Visit lorenzo's homepage! Find more posts by lorenzo Add lorenzo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

cosi è un'altra storia rispetto a quello che avevo provato io...io praticamente ottenevo i gioreni, minuti e secondi trascorsi dal tal giorno cosi invece dovrebbe funzionare.
Ora non ho tempo di porvare perchè ho altro da studiare...cmq se poi funzioan veramente di offro un caffe alla macchinetta del caffe di DSI (o del DICO...scegli te! ;P)

__________________
http://www.twitter.com/0m4r

07-04-2003 19:04
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.86 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:42:50 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Lorenzo sei un grande....funziona!
grazie!

__________________
http://www.twitter.com/0m4r

07-04-2003 20:53
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 23:30.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.116 seconds (74.52% PHP - 25.48% MySQL) con 25 query.