Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • to 1: a list...element 0 for hours etc.. but on a second look it will be easier to create only 1 object because the duration class got methods like getHouts(), getMinutes() and getSeconds() to 2: thanks..ill try it Commented Nov 24, 2011 at 13:27
  • thanks for 2. ...its workin but looks awful in my program code, converting from string[] to int[] and creating the newDuration with a switch/case statement because of all those different parameters. Commented Nov 24, 2011 at 14:18
  • Are you sure you need to use the javax.xml.datatype.Duration class in the first place? As others have stated, it's designed to be used with the Java XML library. Looking at your other question, if you want to just store the length of a CD track, I'd use a plain old int and store the duration in seconds, much like Mansoor's answer (or use the joda-time.sourceforge.net library, if I expect that I'll need to write a lot of code dealing with times, dates and/or durations). Commented Nov 24, 2011 at 14:31
  • well...thanks everyone. i created a class Duration with private classvariable int intSongDuration and String printSongDuration. that class also has a method public String intToStringDuration(intaDuration) which converts the int aDuraation into a hh:mm:ss String. Commented Nov 25, 2011 at 14:55