0

I have ApproveDate.java as type and RestEndpoint.java as Endpoint for Rest webservice.

ApproveDate.java

@XmlElement(name = "ApprovedDate", type = String.class) 
@XmlSchemaType(name = "date")
protected LocalDate approvedDate;       // LocalDate is org.joda.LocalDate


RestEndPoint.java

@GET
@Path("/{id}")
@Transactional
public Response getApprovedDate(@HeaderParam(CONTENT_TYPE) final String contentType) throws SQLException
{
    ApproveDate apd = methodToGetDateFromDB; // here date is coming as "2014-01-01"  from DB
    return Response.ok(apd, contentType).build();
}

Problem here is that, When I am calling this rest services from postman then it is giving me the proper approve date in milisecond when I am having the timezone UTC +5 (IST)

But same service is giving me the approve date as 1 day less in milisecond when I am having timezone UTC-7 (US/Canada). The Response in my RestEndPoint.java is getting proper . I think this is something related to timezone while sending the response back to Postman.

Could anybody provide the reason behind that why this is happening and how can I solve this issue.

ashishl
  • 201
  • 5
  • 12
  • Just to be clear, could you show the exact date/time that you are getting for IST and UTC-7? – notionquest Nov 14 '16 at 11:50
  • On both timezone giving me the same result.. As this is showing to user depend on the in which timezone the application is running. In UTC 5 result in milisecond 1388514600000 In UTC-7 (US/Canada) result in milisecond 1388514600000 As the application is running on the different timezone that why the conversion is happening on the basis of the application running timezone. – ashishl Nov 14 '16 at 11:56
  • I probably have misunderstood your comment, but if you return the same data from db for both requests, than the `ts` is the same. `ts` is the same everywhere on earth. But the string interpretation of that `ts` should be based on the users time zone or a fixed application time zone. Time**stamp** is the same (UTC/GMT base), interpretation based on user/app. Meaning your given `ts` is actually "2013-12-31T18:30:00+00:00" UTC/GMT. Let me know if I've misunderstood you. – zyexal Nov 14 '16 at 15:06
  • Yes.it's perfectly right..but now how can i handle this situation. where I have to change so that i will get the same response in both timezone. – ashishl Nov 15 '16 at 04:58
  • Actually I thought you said that you get the same response `1388514600000 `. Are you looking for something [like this](http://stackoverflow.com/questions/2519432/jaxb-unmarshal-timestamp)? Please just add the responses you get for both to the question. – zyexal Nov 15 '16 at 08:04

0 Answers0