Joda-Time: Period to string

Posted by tt on Stack Overflow See other posts from Stack Overflow or by tt
Published on 2009-09-17T18:28:40Z Indexed on 2010/05/10 7:54 UTC
Read the original article Hit count: 376

Filed under:
|
|

I'm using the Joda-Time library with Java. I'm having some difficulty trying to turn a Period object to a string in the format of "x days, x hours, x minutes".

These Period objects are first created by adding an amount of seconds to them (they are serialized to XML as seconds and then recreated from them). If I simply use the getHours() etc. methods in them, all I get is zero and the total amount of seconds with getSeconds.

How can I make Joda calculate the seconds into the respective fields, like days, hours, etc...?

© Stack Overflow or respective owner

Related posts about java

Related posts about jodatime