Results 1 to 2 of 2
  1. #1
    the phantom is offline Member
    Join Date
    Oct 2011
    Rep Power

    Default Date value passed to a web service

    Hi everyone,

    I'm building an Android app and need to pass a date value into a web service. I've created a standard date variable that grabs the current date and time, then used the SimpleDateFormat method to convert it into a String of my desired format but then I need to convert that string back to a date object so it can be given to the web service.

    I've tried the following however it doesn't convert utilDate into the desired format?;

    java.util.Date utilDate = null;
    Date rightNow = new Date();
    String TodayDate;

    SimpleDateFormat dateformatMddyyyy = new SimpleDateFormat("M-dd-yyyy");
    StringBuilder nowMddyyyy = new StringBuilder( dateformatMddyyyy.format( rightNow ) );
    TodayDate = nowMddyyyy.toString();
    try {
    utilDate = dateformatMddyyyy.parse(TodayDate);
    } catch (ParseException e) {
    // TODO Auto-generated catch block

    I'm very new to Java so I appologise if there is a glaringly obvious way to do this!

  2. #2
    the phantom is offline Member
    Join Date
    Oct 2011
    Rep Power

    Default Re: Date value passed to a web service

    I've just discovered the variable which already creates the date in the format that I need but passing it to the web service produces an error that says 'Cannot Serialize' ?

    Anyone know what that means?

Similar Threads

  1. Replies: 5
    Last Post: 02-16-2012, 10:26 AM
  2. Replies: 4
    Last Post: 07-27-2011, 11:57 AM
  3. entities are passed by value or passed by reference
    By syntrax in forum New To Java
    Replies: 1
    Last Post: 12-17-2009, 08:13 AM
  4. how to call service method inside another service
    By kirtichopra2003 in forum Web Frameworks
    Replies: 1
    Last Post: 10-24-2009, 02:19 AM
  5. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 09:10 AM

Posting Permissions

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