Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would suggest accepting the date as a <code>String</code> and parsing it yourself. Like so:</p> <pre><code>@GET @Path("/generateInfo") @Produces(MediaType.APPLICATION_JSON) public String generateInfo( @QueryParam("a") String a, @QueryParam("b") String b, @QueryParam("date") String date) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date dateObj = sdf.parse(date); return "hello world"; }</code></pre> <p>The way to make this request via a browser is:</p> <pre><code>http://localhost/your_service/generateInfo?date=2013-02-14</code></pre> <p>Things to consider when parsing dates:</p> <ul> <li><p><code>SimpleDateFormat</code> is very flexible with parsing different date formats. The <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO standard for date</a> strings is: <code>yyyy-MM-dd</code></p></li> <li><p>The <a href="http://joda-time.sourceforge.net/">Joda Java date API</a> is accepted as a more complete implementation of date/time, and <a href="http://mike-java.blogspot.co.uk/2008/02/java-date-time-api-vs-joda.html">some believe that it is more optimised than Java's native date API</a> particularly for parsing dates.</p></li> <li><p>it is often better to provide dates as epoch timestamps, especially if your application operates over different timezones. However, you must be aware of HTTP caching issues when accepting epoch timestamps (e.g. if your clients are not truncating epoch timestamps then you will get lots of cache misses). I would refer back to <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601</a> as formatted dates are easier to HTTP cache.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload