Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7597437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:09:24+00:00 2026-05-30T22:09:24+00:00

I have a service defined as follows. public String getData(@QueryParam(date) Date date) I’m trying

  • 0

I have a service defined as follows.

public String getData(@QueryParam("date") Date date)

I’m trying to pass a java.util.Date to it from my client (which is jaxrs:client of CXF, not a generic HTTP client or browser).

My service receives the date as Thu Mar 01 22:33:10 IST 2012 in the HTTP URL. Since CXF won’t be able to create a Date object using this String, my client receives a 404 error.
I tried using a ParameterHandler on the service side, but I still can’t parse it successfully because I’m not expecting the date in any specific format.

As per this post, passing a Date is supposed to work out of the box, but I can’t seem to get the basic case working. Am I required to do anything in order to successfully pass a Date object from my client to service? Appreciate any help.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:09:25+00:00Added an answer on May 30, 2026 at 10:09 pm

    The problem is that JAX-RS dictates that parameter unbundling be done in one of two ways:

    1. The parameter bean has a public constructor that accepts a String
    2. The parameter bean has a static valueOf(String) method.

    In your case, the Date is being unbundled via its Date(String) constructor, which cannot handle the input format your client is sending. You have a couple options available to remedy this:


    Option 1

    Get your client to change the format of the date before they send it. This is the ideal, but probably the hardest to accomplish!


    Option 2

    Handle the crazy date format. The options for this are:

    Change your method signature to accept a string. Attempt to construct a Date object out of that and if that fails, use your own custom SimpleDateFormat class to parse it.

    static final DateFormat CRAZY_FORMAT = new SimpleDateFormat("");
    
    public String getData(@QueryParam("date") String dateString) {
        final Date date;
        try {
            date = new Date(dateString); // yes, I know this is a deprecated method
        } catch(Exception e) {
            date = CRAZY_FORMAT.parse(dateString);
        }
    }
    

    Define your own parameter class that does the logic mentioned above. Give it a string constructor or static valueOf(String) method that invokes the logic. And an additional method to get the Date when all is said and done.

    public class DateParameter implements Serializable {
        public static DateParameter valueOf(String dateString) {
            try {
                date = new Date(dateString); // yes, I know this is a deprecated method
            } catch(Exception e) {
                date = CRAZY_FORMAT.parse(dateString);
            }
        }
    
        private Date date;
        // Constructor, Getters, Setters
    }
    
    public String getData(@QueryParam("date") DateParameter dateParam) {
        final Date date = dateParam.getDate();
    }
    

    Or finally, you can register a parameter handler for dates. Where its logic is simply the same as mentioned for the other options above. Note that you need to be using at least CXF 2.5.3 in order to have your parameter handler evaluated before it tries the default unbundling logic.

    public class DateHandler implements ParameterHandler<Date> {
        public Map fromString(String s) {
            final Date date;
            try {
                date = new Date(dateString); // yes, I know this is a deprecated method
            } catch(Exception e) {
                date = CRAZY_FORMAT.parse(dateString);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service defined as follows: Imports System.ServiceModel Imports System.ServiceModel.Web <ServiceContract()> Public
I have WCF service that return Json. Data contract defined below [DataContract] public class
I have defined a web service that will return the data from my mysql
Let's say I have some classes defined as follows: class Security { Boolean AuthenticateUser(String
I have my JSF Handler defined in request scope as follows public class JsfHandler
We have a service account defined for anonymous access which is used for several
I have a service which has one endpoint , I have defined this endpoint
I have a web service, defined(WSDL) and implemented in PHP. This one is relatively
I have defined small MXML component which calls web service which returns random number
I have defined my Enums like this. public enum UserType { RESELLER(Reseller), SERVICE_MANAGER(Manager), HOST(Host);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.