• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.util.Date

 
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have date input like

want to attain this information with this date time formate..



can any body explain
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at the SimpleDateFormat class. It can parse a string from your input format to a Date object, and then format a string out from that Date object.

Henry
 
akhter wahab
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


i did this what i have to do for finding this Difference 77:17:14 Difference in Days 3.2
and its output is

why its 10/21/2010 ?? it should 10/20/2010
 
akhter wahab
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i use this


its output is Days Between Thu Oct 21 00:50:11 PKST 2010 and Mon Nov 08 19:06:04 PKT 2010 is 18

but still its not fullfiling my requirment of Difference in Days 3.2

and still now can't found any way for Difference 77:17:14 this
 
akhter wahab
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any help
 
Ranch Hand
Posts: 317
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

akhter wahab wrote:why its 10/21/2010 ?? it should 10/20/2010



The string date is actually 5 hours behind GMT and your current time zone seems to be in Pakistan which is +5/+6 hours ahead of GMT. Hence the difference.

akhter wahab wrote:
its output is Days Between Thu Oct 21 00:50:11 PKST 2010 and Mon Nov 08 19:06:04 PKT 2010 is 18

but still its not fullfiling my requirment of Difference in Days 3.2



The sample dates that you are using here are different from the ones in your original post. The difference looks to be ok. Try using

(float)(24 * 3600 * 1000)

to get more precise values.


 
akhter wahab
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sridhar Santhanakrishnan wrote:

akhter wahab wrote:why its 10/21/2010 ?? it should 10/20/2010



The string date is actually 5 hours behind GMT and your current time zone seems to be in Pakistan which is +5/+6 hours ahead of GMT. Hence the difference.

akhter wahab wrote:
its output is Days Between Thu Oct 21 00:50:11 PKST 2010 and Mon Nov 08 19:06:04 PKT 2010 is 18

but still its not fullfiling my requirment of Difference in Days 3.2



The sample dates that you are using here are different from the ones in your original post. The difference looks to be ok. Try using

(float)(24 * 3600 * 1000)

to get more precise values.




thanks it really helps me allot

and still now can't found any way for Difference 77:17:14
 
Sridhar Santhanakrishnan
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

c2.getTime().getTime() - c1.getTime().getTime()



1) This gives the time in millis.
2) divide by 1000 to get the total number of seconds.
3) divide the resulting number by 3600 to get the hours.
4) divide the remainder by 60 to get the minutes.
5) the remainder, now should be the seconds.
try using the modulo operator.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic