This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

java.util.Date

 
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
  • 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: 23855
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
any help
 
Ranch Hand
Posts: 317
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
Get me the mayor's office! I need to tell her about this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!