• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Java code for converting seconds into Days ,Hours and Minutes

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It doesn't work like that. We're NotACodeMill. What have you tried so far? What didn't work?
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would recommend the Joda-Time library
The Period and PeriodFormat classes look very relevant.
 
reply
    Bookmark Topic Watch Topic
  • New Topic