For full functionality of this site it is necessary to enable JavaScript.
Here are the instructions how to enable JavaScript in your web browser.

Knowledge base

Find the answer to your question

Advanced Search PView

Search terms
Search Type
Product
Category
Language
Format
SDK
Sort by
Direction

Parse Duration data type in Java.

  • Answer ID 1145
  • Published 09/12/2007 05:40 PM
  • Updated 10/20/2013 06:41 AM
  • Permalink https://ebaydts.com/eBayKBDetails?KBid=1145
There is no data wrapper type in the eBay JAVA SDK nor in javax.xml, how can I parse the Duration value returned in GetItem call?

Detailed Description
 

    The Item TimeLeft element is represented in the standard Duration ISO 8601 format : PnYn MnDTnH nMnS. In JAVA SDK the property is returned in ItemType.getTimeLeft() getter in the object of org.apache.axis.types.Duration type.

   To parse the value, you just simply call the getTimeLeft() getter of the ItemType object directly as  :

   String itemID ="";
   ItemType item = new ItemType(new ItemIDType(itemID));


   System.out.println(item.getTimeLeft());

   System.out.println("Time Left :  [ D"+item.getTimeLeft().getDays() +" H" +item.getTimeLeft().getHours()+ " M" +item.getTimeLeft().getMinutes() + " ]" );

  The output of the above code snippet are :

   P6DT23H38M52S

  Time Left : [ D6 H23 M38 ]


Version Info

The code example above was based on the versions specified below:

API Schema Version 529

Additional Resources

How well did this answer your question?

Answers others found helpful

Print Email This Page Delicious Digg Facebook Reddit StumbleUpon Twitter