File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java code for converting seconds into Days ,Hours and Minutes

 
Deepak Sahu
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody can someone provide me the Java code for converting seconds into Days ,Hours and Minutes




for example


1 Day 2 Hr 20 Min =24*60*60 + 2*60*60 + 20*60= 94800 Seconds

Similarly if we input 94800, the output should be 1 Day 2 Hr 20 Min


 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't work like that. We're NotACodeMill. What have you tried so far? What didn't work?
 
Rob Spoor
Sheriff
Pie
Posts: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know how to convert days, hours and minutes into seconds. Converting seconds into days, hours and minutes is the inverse. The only "difficult" part is the splitting of one value into three values. Any part smaller than 1 day will be hours plus minutes; any part smaller than 1 hour will be minutes.
 
Stefan Evans
Bartender
Posts: 1640
9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would recommend the Joda-Time library
The Period and PeriodFormat classes look very relevant.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic