0
<?xml version="1.0" encoding="UTF-8"?>
<digitalObjectWrapper>
<count>1</count>
<entities>
  <entity>
     <baseId>24</baseId>
     <startDate>2015-09-02T19:06:08.839+02:00</startDate>
     <endDate>2015-09-07T14:33:46.909+02:00</endDate>
     <note>Ingest1</note>
  </entity>
</entities>
</digitalObjectWrapper>

This is my xml data and from this tag <startDate>2015-09-02T19:06:08.839+02:00</startDate> i just want 2015-09-02 19.06 while parsing.

How can i achieve that ?

MMK
  • 609
  • 5
  • 16
Haseb Ansari
  • 587
  • 1
  • 7
  • 23
  • 1
    You should not mix parsing XML and business logic. First, parse correctly the XML, storing the `startDate` and `endDate` in `Date` objects. Then, apply your business logic to discard seconds and milliseconds. – Tunaki Sep 07 '15 at 19:25
  • 1
    please make a search. check this question: http://stackoverflow.com/questions/4076910/how-to-retrieve-element-value-of-xml-using-java – Eng. Samer T Sep 07 '15 at 20:02
  • i have parsed the data but it all comes as one string.....i need to delete some characters from the string. – Haseb Ansari Sep 07 '15 at 20:55
  • and this does not only contain seconds n millisec it has GMT and a letter T in between – Haseb Ansari Sep 07 '15 at 21:58

1 Answers1

0

Keep two static final format strings i.e. one for source format another for target format. Once reading this date string from xml, convert to target format using simpledateformat.

Raman Shrivastava
  • 2,923
  • 15
  • 26