Results 1 to 12 of 12
  1. #1
    royroy7 is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default java wcf nodelist types

    hi

    im using this code to get my object from wcf :
    Java Code:
    NodeList nodes =Tools.GetNodeList(MessageFormat.format(loginUrl,appLogin.GetKey(),appLogin.GetClientID(),profID),"/ArrayOfEvent/Event"); 
        //(NodeList)xPath.evaluate("/ArrayOfEvent/Event",response,XPathConstants.NODESET);               
        int nodeCount = nodes.getLength(); 
     
     
        //iterate over search Result nodes 
        XPathFactory factory = XPathFactory.newInstance();         
        XPath xPath=factory.newXPath(); 
     
        for (int i = 0; i < nodeCount; i++) {         
            String venue = xPath.evaluate("Venue", nodes.item(i)); 
            Date startDate = Date.valueOf(xPath.evaluate("StartDate", nodes.item(i))); 
            Date endDate = Date.valueOf(xPath.evaluate("EndDate", nodes.item(i))); 
     
            Event ev = new Event(venue,startDate,endDate); 
            list.add(ev); 
     
        } 
        } 
        catch (Exception e) { 
            e.printStackTrace(); 
        }
    1.i hope im doing it in the right way, if not please let me know
    2.i get exception when im getting to the Date parsing startDate and enddate

    how can i get the date? thats example of the xml i get from wcf-rest:

    Java Code:
    >
    <ArrayOfEvent>
    <Event>
    <CompanyName></CompanyName>
    <Description></Description>
    <EndDate>2012-05-08T00:00:00</EndDate>
    <Id>3954</Id>
    <Logo>3954.png</Logo>
    <Name>aaa2012</Name>
    <ShortEventName>Miltech</ShortEventName>
    <StartDate>2012-05-08T00:00:00</StartDate>
    <Subtitle i:nil="true"/>
    <Venue></Venue>
    </Event>
    </ArrayOfEvent>

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: java wcf nodelist types

    IF you tell us _what_ exception (stack trace please!) you get one might help...

  3. #3
    royroy7 is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: java wcf nodelist types

    Quote Originally Posted by Sierra View Post
    IF you tell us _what_ exception (stack trace please!) you get one might help...
    unable to parse '08T00:00:00' as integer

    thats how the wcf send me the date, the problame is that i dont know hoe to convert this date node to java date
    Last edited by royroy7; 04-29-2012 at 03:26 PM.

  4. #4
    royroy7 is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: java wcf nodelist types

    ok now after i change it to :
    Date startDate = (Date) new SimpleDateFormat().parse(xPath.evaluate("StartDate ", nodes.item(i)));

    i got this error:
    java.text.ParseException: Unparseable date: "2012-05-14T00:00:00"

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  6. #6
    royroy7 is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: java wcf nodelist types

    thanks.
    this code is working :
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date startDate = formatter.parse(xPath.evaluate("StartDate", nodes.item(i)).replace("T"," "));
    Date endDate = formatter.parse(xPath.evaluate("EndDate", nodes.item(i)).replace("T"," "));

    is it correct writing?

  7. #7
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: java wcf nodelist types

    You do not even have to replace the "T" - just include it in the formatter's format string.
    Here is more of the API : SimpleDateFormat (Java 2 Platform SE v1.4.2)

  8. #8
    royroy7 is offline Member
    Join Date
    Apr 2012
    Posts
    5
    Rep Power
    0

    Default Re: java wcf nodelist types

    i did not find any format with T ,when i tried to add it to the format i got exception.

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: java wcf nodelist types

    Quote Originally Posted by Sierra View Post
    Please don't post links to old versions that have long been EOL. Bookmark these:
    Java Platform SE 6
    Java Platform SE 7

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  10. #10
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: java wcf nodelist types

    Quote Originally Posted by royroy7 View Post
    i did not find any format with T ,when i tried to add it to the format i got exception.
    To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  11. #11
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: java wcf nodelist types

    Quote Originally Posted by DarrylBurke View Post
    Please don't post links to old versions that have long been EOL.
    I googled it and I did not care about the version to be honest. You are probably right - when I know which version he uses I do and it hasn't changed that much in usage anyway.
    So here you go: SimpleDateFormat (Java Platform SE 7 )

    EDIT: I use it with the "T" (included correctly) every day and it works for me, but maybe your timestamp or java version is another one.
    Last edited by Sierra; 04-29-2012 at 09:53 PM.

  12. #12
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: java wcf nodelist types

    Sierra

    The problem isn't about the specific class for which you posted an API link. Others who come across this thread may follow that link and then be unable to find another class or method that was introduced in a later version, leading to some confusion.

    Google searches always push old API to the top, simply because the page hit count and search click-through count are obviously vastly higher than for the newer versions. I guess HTML could do with some sort of @Deprecated META tag :)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Java Data Types ?!
    By HearT.Hunt3r in forum New To Java
    Replies: 4
    Last Post: 08-09-2011, 05:43 PM
  2. Replies: 6
    Last Post: 07-22-2011, 03:05 PM
  3. encryption types in java
    By vasantharaman24@gmail.com in forum Suggestions & Feedback
    Replies: 0
    Last Post: 10-22-2008, 03:55 PM
  4. How to get NodeList from XML file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-13-2007, 10:16 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •