コード例 #1
0
  private void common(final Element input, final AtomObject object) {
    if (StringUtils.isNotBlank(input.getAttribute(ODataConstants.ATTR_XMLBASE))) {
      object.setBaseURI(input.getAttribute(ODataConstants.ATTR_XMLBASE));
    }

    final List<Element> ids = XMLUtils.getChildElements(input, ODataConstants.ATOM_ELEM_ID);
    if (!ids.isEmpty()) {
      object.setId(ids.get(0).getTextContent());
    }

    final List<Element> titles = XMLUtils.getChildElements(input, ODataConstants.ATOM_ELEM_TITLE);
    if (!titles.isEmpty()) {
      object.setTitle(titles.get(0).getTextContent());
    }

    final List<Element> summaries =
        XMLUtils.getChildElements(input, ODataConstants.ATOM_ELEM_SUMMARY);
    if (!summaries.isEmpty()) {
      object.setSummary(summaries.get(0).getTextContent());
    }

    final List<Element> updateds =
        XMLUtils.getChildElements(input, ODataConstants.ATOM_ELEM_UPDATED);
    if (!updateds.isEmpty()) {
      try {
        object.setUpdated(ISO_DATEFORMAT.parse(updateds.get(0).getTextContent()));
      } catch (Exception e) {
        LOG.error("Could not parse date {}", updateds.get(0).getTextContent(), e);
      }
    }
  }
コード例 #2
0
  public void testPartialParse() throws Exception {
    java.text.ParsePosition pos = new java.text.ParsePosition(0);
    String timestamp = "2007-08-13T19:51:23Z";
    Date result = df.parse(timestamp + "hello", pos);

    assertEquals(date, result);
    assertEquals(timestamp.length(), pos.getIndex());
  }
コード例 #3
0
 public void testParse() throws Exception {
   Date result = df.parse("2007-08-13T19:51:23Z");
   assertEquals(date, result);
 }