views:

42

answers:

2

I'm using Simple Framework for my recent project, and there is a problem with the date headers generated by the system. I can get my local time from Date class correctly, but setDate method of Simple's Response class sets date in milliseconds and when i do that by calling System.currentTimeInMillis, dates in response headers are incorrect. is there any way to solve this problem with Simple Framework? If not, what can i do except calling set method with a date string? Thanks in advance...

EDIT: Date in the headers are in wrong timezone. And i also tried Calendar.getInstance().getTimeInMilis() method.

A: 

Have you tried the Calendar object? It can easily be converted to milliseconds by calling its getTimeInMillis() method:

Calendar.getInstance().getTimeInMillis()
Marc
A: 

Are your dates in GMT? If not then what are they in. Don't forget the HTTP/1.1 spec says the following.

RFC 2616 HTTP/1.1 June 1999

All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception. For the purposes of HTTP, GMT is exactly equal to UTC (Coordinated Universal Time). This is indicated in the first two formats by the inclusion of "GMT" as the three-letter abbreviation for time zone, and MUST be assumed when reading the asctime format. HTTP-date is case sensitive and MUST NOT include additional LWS beyond that specifically included as SP in the grammar.

ng
They are in UTC i think, i live in GMT+3 time zone, and last modified header of response is 3 hours earlier, which may cause a cache problem with browsers
Deniz Acay
That sounds correct the Date: and Last-Modified: in the HTTP/1.1 response should be three hours out if you live in GMT + 3. Your cache will know because all HTTP/1.1 headers must be in RFC 1123 format which contains the time zone. For example from RFC 2616, "Sun, 06 Nov 1994 08:49:37 GMT".
ng
Oh, i see, so i don't have to worry about timezone when it comes to browser caching because it's standard in HTTP implementations, thank you very much!
Deniz Acay